1Z0-1067-25 Question 24
Select 3Your DevOps team is building a new microservices-based e-commerce platform in Oracle Cloud Infrastructure using Terraform for Infrastructure as Code. You plan to replicate the same architecture across multiple environments: development, staging, and production. Which three design choices will allow you to reuse the same Terraform code with minimal modifications across these environments?
- A
Use variable definitions in .tfvars files to manage environment-specific values, eliminating the need to modify the main Terraform code base.
- B
Hard-code regional and compartment details within the Terraform modules for consistent usage across environments.
- C
Leverage environment variables for sensitive information, referencing them in your Terraform configuration through input variables.
- D
Maintain separate Terraform state files for each environment to avoid conflicts and ensure isolation.
- E
Embed environment-specific logic (e.g., region mapping, compartment IDs) directly in a single main.tf file.
Show answer and explanation
Correct answers: A, C, D
Explanation
To deploy replicable stacks in OCI using Infrastructure as Code, it� recommended to use Terraform variables, environment variables for sensitive data, and separate state files per environment. This approach is aligned with Terraform best practices and OCI Resource Manager guidelines, allowing you to maintain consistent configurations while isolating environment-specific data. Refer to HashiCorp� Terraform documentation and Oracle� official Terraform Provider documentation for details on structuring variables, state management, and environment-specific configuration.
- A. Correct.
Correct. Using .tfvars files for environment-specific configurations is a recommended Terraform practice. It allows you to maintain one code base while supplying different parameters (such as region, compartment OCIDs, or instance shapes) in separate files, reducing the chance of errors and the need to manually edit the main code.
- B. Incorrect.
Incorrect. Hard-coding details such as region or compartment in your Terraform modules makes your code less flexible. It forces you to modify the code itself whenever you change environments, which undermines the goal of having a reusable stack.
- C. Correct.
Correct. Storing sensitive information as environment variables and referencing them through Terraform input variables helps keep credentials secure and separate from the code. It also minimizes duplicative changes when switching environments.
- D. Correct.
Correct. Separate state files for each environment prevent resource collisions and help isolate changes. Each environment can be managed independently without overwriting or corrupting another environment� state.
- E. Incorrect.
Incorrect. Including all environment-specific logic in a single file goes against modular design and can lead to a cluttered configuration. It becomes difficult to maintain, debug, or extend for new environments.