0 votes
in AWS by

A company has a Cloudformation template that is used to create a huge list of resources. It creates a VPC, subnets, EC2 Instances, Autoscaling Groups, Load Balancers etc.

Which of the following should be considered when designing such Cloudformation templates?

1 Answer

0 votes
by

Answer - B.

This recommendation is also given in the AWS Documentation.

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::Stack resource in your template to reference other templates.

Option A is incorrect since this is not the recommended design practice.

Options C and D are incorrect because these are used for packaging and deployment and not for the design stages.

For more information on best practices for Cloudformation, please refer to the below URL-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html

When designing CloudFormation templates for creating a large number of resources like VPC, subnets, EC2 Instances, Autoscaling Groups, Load Balancers etc., it is essential to consider the following points:

A. Ensure to create one entire stack from the template: Creating one entire stack from the template ensures that all the resources are deployed together in a consistent and reliable manner. However, this approach has some limitations, such as the number of resources that can be created in a single stack, the time required to deploy all the resources, and the complexity of updating or deleting the stack.

B. Look towards breaking the templates into smaller manageable templates: Breaking the templates into smaller, manageable templates can help to overcome the limitations of creating one entire stack from the template. This approach helps to manage the resources in a more granular manner, making it easier to update, delete or rollback specific resources, without affecting the others. It also helps to speed up the deployment time by deploying resources in parallel. However, it increases the complexity of managing multiple templates and their dependencies.

C. Package the templates together and use the cloudformation deploy command: Packaging the templates together helps to simplify the deployment process and reduce the chances of errors. The CloudFormation deploy command can be used to create and deploy the entire stack or a specific resource within the stack. It also provides the option to roll back the deployment if any error occurs.

D. Package the templates together and use the cloudformation package command: The CloudFormation package command can be used to upload the templates and the associated files to an S3 bucket. This approach helps to manage the template files, reduces the template size, and speeds up the deployment process. The packaged templates can then be deployed using the CloudFormation deploy command.

In conclusion, it is recommended to break down the CloudFormation templates into smaller manageable templates, package them together, and use the CloudFormation deploy command for deployment, to ensure the resources are deployed consistently and reliably.

...