DOP-C02 Question 94
Select 3A company is using AWS CloudFormation to manage its infrastructure as code (IaC). The DevOps team is tasked with ensuring the infrastructure templates can be reused across multiple environments (e.g., dev, test, and prod) with minimal changes. Which features or approaches can be used to achieve this?
- A
Use CloudFormation parameters to pass environment-specific values to the template at runtime.
- B
Define multiple templates for each environment to handle environment-specific configurations.
- C
Leverage CloudFormation mappings to define environment-specific settings within a single template.
- D
Use AWS CloudFormation StackSets to manage deployment across multiple accounts and regions.
- E
Incorporate AWS Systems Manager Parameter Store to dynamically retrieve environment-specific values during template execution.
Show answer and explanation
Correct answers: A, C, E
Explanation
To create reusable CloudFormation templates that work across multiple environments, leveraging parameters, mappings, and external tools like AWS Systems Manager Parameter Store is critical. Parameters allow runtime customization, mappings handle environment-specific logic within a single template, and Parameter Store provides a secure way to fetch dynamic values. These approaches align with IaC best practices and reduce template duplication and maintenance effort.
- A. Correct.
Using CloudFormation parameters is a best practice for creating reusable templates. Parameters allow you to specify environment-specific values (e.g., AMI IDs, instance types) at runtime without modifying the template itself.
- B. Incorrect.
Defining multiple templates for each environment is not efficient or scalable. It increases the maintenance overhead and contradicts the principle of reusable infrastructure as code.
- C. Correct.
CloudFormation mappings allow you to define key-value pairs that can vary based on environment or region. This enables you to handle environment-specific configurations within a single template.
- D. Incorrect.
While StackSets enable deployment across multiple accounts and regions, they are more suited for multi-account management rather than reusing templates in a single account across environments.
- E. Correct.
AWS Systems Manager Parameter Store can be used to dynamically retrieve environment-specific values (e.g., database credentials, configuration settings) during CloudFormation stack execution, reducing hardcoding and improving reusability.