DOP-C02 Question 87
Select 3Your organization wants to implement infrastructure as code (IaC) principles to provision and manage cloud systems throughout their lifecycle. The team has chosen AWS CloudFormation for this purpose. To ensure reusability and adherence to best practices, you are tasked with designing reusable components for the infrastructure. Which of the following approaches should you take to define and manage reusable CloudFormation templates effectively?
- A
Use CloudFormation nested stacks to modularize the infrastructure and enable reuse of common resources.
- B
Leverage AWS CloudFormation StackSets to standardize deployments across multiple AWS accounts and regions.
- C
Store CloudFormation templates in a version-controlled repository like AWS CodeCommit or Git to enable collaboration and versioning.
- D
Hardcode resource values (e.g., instance types, subnets) within the templates to simplify management.
- E
Utilize CloudFormation macros or parameters to make templates flexible and configurable for different environments.
Show answer and explanation
Correct answers: A, C, E
Explanation
To define reusable CloudFormation components that align with best practices, you should focus on modularization (using nested stacks), flexibility (using parameters or macros), and collaboration (using version-controlled repositories). These practices ensure that your infrastructure is easy to manage, scalable, and adaptable to various use cases and environments.
- A. Correct.
CloudFormation nested stacks allow you to modularize your infrastructure by referencing reusable templates, making it easier to manage and update resources across multiple stacks.
- B. Incorrect.
While AWS CloudFormation StackSets are useful for managing stacks across multiple accounts and regions, they are not specifically for creating reusable components within templates.
- C. Correct.
Storing templates in a version-controlled repository ensures collaboration, tracking changes, and maintaining a history of your infrastructure definitions, which aligns with IaC best practices.
- D. Incorrect.
Hardcoding resource values reduces flexibility and reusability, making it difficult to adapt templates to different environments or configurations.
- E. Correct.
CloudFormation macros and parameters make templates flexible by enabling customization for different environments without modifying the core template structure.