1Z0-1067-25 Question 20
Select 2Your organization must replicate a multi-tier application environment across Dev, Staging, and Production compartments in Oracle Cloud Infrastructure (OCI). The team uses Terraform and Oracle Resource Manager for Infrastructure as Code. Which two approaches will best ensure environment consistency across these compartments? (Choose two.)
- A
Hard-code region and compartment IDs in a single Terraform configuration to guarantee all environments share the same settings.
- B
Use Terraform modules that reference variables for region and compartment, and specify environment differences in separate .tfvars files.
- C
Keep state files stored locally for each environment to simplify version control and prevent remote conflicts.
- D
Create multiple stacks in Oracle Resource Manager, each referencing the same core Terraform modules but loading unique variable files for each environment.
- E
Combine all environments into a single stack with a single configuration file and override variables at runtime.
Show answer and explanation
Correct answers: B, D
Explanation
To effectively replicate infrastructure across multiple OCI environments using Terraform, it is best practice to externalize environment-specific inputs (region, compartment IDs, etc.) into variables and .tfvars files, and then deploy multiple stacks (or use separate workspaces) for each environment. This approach aligns with OCI Resource Manager guidelines and Oracle� recommended Infrastructure as Code practices for maintainable, reproducible deployments.
- A. Incorrect.
Option 1: Incorrect. Hard-coding region and compartment IDs in a single file makes it difficult to replicate stacks to different environments and often leads to deployment errors or environment misconfiguration.
- B. Correct.
Option 2: Correct. Splitting out region and compartment variables into separate .tfvars files enables consistent yet flexible deployments across multiple environments. Terraform modules streamline common resource definitions while variable files handle specific environment differences.
- C. Incorrect.
Option 3: Incorrect. Storing state files locally complicates collaboration, as state is not easily shared or versioned among team members. OCI best practices recommend remote backends or Resource Manager for managing Terraform state.
- D. Correct.
Option 4: Correct. Creating multiple Resource Manager stacks that share the same Terraform modules but load environment-specific variables ensures each environment can be deployed and updated independently while still adhering to a consistent baseline configuration.
- E. Incorrect.
Option 5: Incorrect. Consolidating all environments into a single stack with a single file can lead to confusion and conflict over variable overrides. It� more effective to maintain separate stacks or workspace configurations for each environment.