DOP-C02 Question 86
Single answerYour organization is building a scalable and reusable cloud infrastructure for multiple environments (e.g., development, staging, production). You are tasked with defining the infrastructure using AWS CloudFormation to ensure consistency and manageability. The solution must allow developers to provision resources independently while adhering to governance policies. Which approach best fulfills these requirements?
- A
Use AWS CloudFormation StackSets to define a single-stack template that deploys resources across all environments with environment-specific parameters defined in the template.
- B
Create separate AWS CloudFormation templates for each environment and manually deploy them as needed.
- C
Implement AWS CloudFormation nested stacks, where a parent stack references reusable child stacks, each defining specific resource types such as networking, compute, and storage.
- D
Define all resources within a single monolithic AWS CloudFormation template and allow developers to update the template directly to provision resources dynamically.
Show answer and explanation
Correct answer: C
Explanation
The best approach to defining reusable cloud infrastructure using AWS CloudFormation is to implement nested stacks. This ensures modularity by breaking down infrastructure into smaller, reusable components, such as networking or compute layers, which can then be referenced by a parent stack. Nested stacks also enforce governance and consistency while allowing developers to provision resources without modifying the core templates directly. This aligns with the principles of infrastructure as code and lifecycle management.
- A. Incorrect.
AWS CloudFormation StackSets are designed for deploying stacks across multiple AWS accounts or regions, not for managing reusable components and environments within a single account. This option does not provide modularity or reusability at the infrastructure component level.
- B. Incorrect.
Creating separate templates for each environment introduces redundancy and is prone to inconsistencies. This approach does not leverage the benefits of reusable components and is less manageable over time.
- C. Correct.
AWS CloudFormation nested stacks allow you to modularize your infrastructure by separating resources into reusable and maintainable child stacks. This approach promotes consistency across environments and enables developers to provision resources independently while adhering to predefined templates.
- D. Incorrect.
A monolithic template lacks modularity, making it difficult to manage and maintain as the infrastructure grows. Allowing developers to directly update the template also introduces governance risks and potential misconfigurations.