DOP-C02 Question 83
Single answerYou are managing a multi-environment setup (development, staging, and production) using AWS CloudFormation. Each environment requires slightly different configuration values, such as instance types, database sizes, and environment-specific tags. You need to ensure these configurations are reusable, maintainable, and easily deployable across environments. Which approach should you choose to manage these environment-specific configurations effectively?
- A
Use separate CloudFormation templates for each environment to define the specific configurations.
- B
Embed environment-specific values directly into the CloudFormation template as hard-coded values.
- C
Utilize CloudFormation parameters and pass environment-specific values during stack creation.
- D
Use AWS CloudFormation StackSets to define environment-specific configurations within a single stack.
Show answer and explanation
Correct answer: C
Explanation
The best practice for managing environment-specific configurations in AWS CloudFormation is to use parameters. Parameters make your templates reusable and allow you to pass environment-specific values dynamically during stack creation. This approach minimizes duplication, simplifies maintenance, and adheres to infrastructure as code best practices.
- A. Incorrect.
This approach is not optimal because maintaining separate templates for each environment increases complexity and duplication, which violates best practices for infrastructure as code.
- B. Incorrect.
Hard-coding environment-specific values directly into the template makes it less reusable and harder to maintain across multiple environments, violating the principle of DRY (Don't Repeat Yourself).
- C. Correct.
This is the correct answer. Using CloudFormation parameters allows you to define reusable templates and provide environment-specific values dynamically at deployment time, ensuring flexibility and maintainability.
- D. Incorrect.
While StackSets are useful for managing stacks across multiple AWS accounts or regions, they are not designed for handling environment-specific configurations within the same account. This approach is not the best fit for the given scenario.