You have been requested to use CloudFormation to maintain version control and achieve automation for the applications in your organization.
Which of the following options is the best practice to keep everything agile and maintain multiple environments?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - A.
As your infrastructure grows, common patterns can emerge in which you declare the same components in each of your templates.
You can separate out these common components and create dedicated templates for them.
That way, you can mix and match different templates but use nested stacks to create a single, unified stack.
Nested stacks are stacks that create other stacks.
To create nested stacks, use the AWS::CloudFormation::Stackresource in your template to reference other templates.
For more information on Cloudformation best practices, please refer to the below link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.htmlThe correct answer for this question is A. Create separate templates based on functionality and create nested stacks with CloudFormation.
Explanation: CloudFormation is a service provided by AWS that allows users to model and provision AWS resources through templates. These templates are JSON or YAML formatted files that define the infrastructure as code. CloudFormation templates can be version controlled and maintained, which makes them ideal for automation and achieving agility.
When creating CloudFormation templates, it is recommended to keep them modular and split them based on functionality. This way, it becomes easier to manage the templates and also facilitates reusability. When a change is required in a specific functionality, only that template can be modified and updated, instead of modifying the whole CloudFormation stack.
In addition, CloudFormation allows users to create nested stacks, which are stacks that are created as part of a parent stack. This allows for better organization of resources and enables users to create multiple environments using the same templates. For example, a development environment, a testing environment, and a production environment can all be created using the same set of templates.
Using CloudFormation custom resources to handle dependencies between stacks (option B) is also a valid approach. However, it is more complex and not recommended unless required for specific scenarios.
Creating multiple templates in one CloudFormation stack (option C) is not recommended as it makes the templates difficult to manage and update.
Combining all resources into one template for version control and automation (option D) can be done, but it is not a best practice as it becomes difficult to manage and update the template as it grows in complexity.
In summary, the best practice for maintaining version control and achieving automation with CloudFormation is to create separate templates based on functionality and create nested stacks.