1Z0-997-25 Question 23
Select 2You are leading an initiative to implement an Infrastructure as Code approach for automating the provisioning of multiple environments (development and production) in Oracle Cloud Infrastructure (OCI). The development environment will need frequent updates and may be spun up and down often, while the production environment is long-running. Despite these differences, your team wants to reuse the same core Terraform code base to ensure consistency, maintainability, and faster deployments. Which two strategies would best help you manage the environment-specific differences while maximizing code reusability?
- A
Use environment-specific variable files and reference them as needed when applying Terraform configurations.
- B
Hard-code the resource shapes and configurations in a single Terraform configuration file to guarantee consistency across environments.
- C
Create a completely separate Terraform repository for each environment to avoid mixing development and production code.
- D
Leverage Terraform modules with environment-specific inputs to isolate differences and promote reusable code.
Show answer and explanation
Correct answers: A, D
Explanation
Using Terraform effectively in OCI entails leveraging best practices such as modules and variable files. Modules allow consistent provisioning flows across multiple environments, while environment-specific variable files help tailor small differences without duplicating entire configurations. Refer to the official Terraform documentation and Oracle Resource Manager best practices (https://docs.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/resourcemanager.htm) for guidance on structuring code repositories, managing variables, and automating deployments consistently.
- A. Correct.
Correct. Environment-specific variable files allow you to keep a single code base while customizing configurations (e.g., instance shapes or region) for development and production. You can pass in the correct variable file at apply time, avoiding the need for multiple, nearly identical Terraform files.
- B. Incorrect.
Incorrect. Hard-coding shapes and other parameters for all environments in a single file is inflexible and prone to errors when switching between environments. This approach defeats the purpose of Infrastructure as Code reuse and maintainability.
- C. Incorrect.
Incorrect. While creating separate repositories could isolate changes, it also fragments your code base and complicates maintenance. You lose the benefit of sharing and reusing the common logic, making it harder to manage updates and consistency across environments.
- D. Correct.
Correct. Terraform modules provide a structured way to abstract and reuse code. You can pass in different variables to the modules depending on the environment, ensuring only the required parameters differ while the core logic remains consistent.