1Z0-997-25 Question 28
Single answerYour company is deploying a multi-tier web application on Oracle Cloud Infrastructure (OCI) across staging and production environments. The environment includes multiple subnets, compute instances, and a load balancer. The team has decided to use Oracle Resource Manager to deploy Terraform configurations and maintain a single source of truth in a version control system. They want to ensure that environment-specific parameters�such as instance shapes, network CIDR blocks, and compartment details�are configured properly without duplicating large portions of their Terraform code. Which approach best addresses this requirement?
- A
Hardcode all environment-specific parameter values in the main Terraform configuration files.
- B
Use environment-specific variable files (for example, staging.tfvars, production.tfvars) and reference them for each Resource Manager stack.
- C
Create a separate Terraform module for each environment with fully independent configurations.
- D
Manually override parameters during the stack creation process in the Resource Manager console.
Show answer and explanation
Correct answer: B
Explanation
Storing environment-specific parameters in separate variable (.tfvars) files and referencing them in the Oracle Resource Manager stack ensures consistent automation across different environments. This approach keeps your Terraform code DRY (Don�t Repeat Yourself) and aligns with best practices documented in Oracle� Resource Manager and Terraform guidelines, which recommend using variable files for environment-specific configurations to streamline your IaC deployments.
- A. Incorrect.
Option 1 is incorrect because hardcoding environment-specific values increases duplication and maintenance effort. Changing one environment might also unintentionally affect another.
- B. Correct.
Option 2 is correct. Using environment-specific variable files is a best practice to keep most of the code uniform while allowing each environment to override only what differs. Resource Manager supports referencing .tfvars files to customize configurations based on the environment.
- C. Incorrect.
Option 3 is incorrect because while separate modules for each environment can work, it often leads to significant code duplication and complicates version control. A single well-structured module shared across environments is more efficient.
- D. Incorrect.
Option 4 is incorrect because manually overriding parameters goes against the principle of Infrastructure as Code, making deployments less repeatable and more prone to human error.