1Z0-1067-25 Question 21
Single answerYou have a Terraform configuration that successfully deploys a multi-tier application, including VCNs, compute instances, and an Autonomous Database, in your Development compartment on Oracle Cloud Infrastructure. You now need to replicate the exact same configuration in your Production compartment. Which approach should you follow to ensure consistent deployment using Infrastructure as Code best practices?
- A
A) Manually copy and paste each Terraform resource into a new configuration file, adjusting references for Production as needed.
- B
B) Use the same Terraform state file that was used for Development to deploy resources in Production, to keep versions consistent.
- C
C) Commit the existing Terraform code to a source control repository and customize environment-specific variables in a separate .tfvars file, then run a new Terraform workspace or Resource Manager stack for Production.
- D
D) Export the existing environment to an OCI template and upload it into Resource Manager, ignoring any version control or environment-specific variables.
Show answer and explanation
Correct answer: C
Explanation
Best practice in Infrastructure as Code for Oracle Cloud Infrastructure involves keeping your Terraform configurations under version control, using separate workspaces or Resource Manager stacks per environment, and defining environment-specific variables (for example, in .tfvars files). Oracle's Resource Manager supports state isolation for each environment, which prevents cross-environment interference and makes your stacks more robust. Refer to the OCI Resource Manager documentation and Terraform Provider for OCI best practices for further guidance.
- A. Incorrect.
A) Incorrect. Copying and pasting individual resources is error-prone, difficult to maintain, and not aligned with Infrastructure as Code best practices. Consistency can be easily lost, and manual edits often lead to configuration drift.
- B. Incorrect.
B) Incorrect. Reusing the same Terraform state file for Development and Production risks accidental resource modification or deletion. Each environment should maintain a separate state to avoid overlaps and conflicts.
- C. Correct.
C) Correct. Leveraging version control ensures a single source of truth for your code, and using separate .tfvars files or Resource Manager stacks isolates environment-specific settings (e.g., compartment IDs, database sizes). A unique workspace or stack for Production ensures state isolation, preventing any accidental changes to Development resources.
- D. Incorrect.
D) Incorrect. While you can export the environment to an OCI template for Resource Manager, entirely ignoring version control and environment-specific variables goes against recommended Infrastructure as Code workflows. This approach complicates collaboration and introduces potential drift issues over time.