Avoid Errors in CloudFormation Template Deployment | AWS Certified SysOps Administrator Exam SOA-C02

Considerations for Error-Free CloudFormation Template Deployment

Question

Your team is creating a Cloudformation stack that will make use of a template to create a VPC, an Internet gateway and EC2 Instances with public IP address.

Which of the following should you consider to avoid running into errors in the template deployment?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: B.

The AWS Documentation mentions the following.

Option A is incorrect since this is used to accept dynamic parameters in the template.

Option C is incorrect since the DeletionPolicy attribute is used to preserve or backup a resource when its stack is deleted.

Option D is incorrect since the UpdatePolicy attribute is used to specify how AWS CloudFormation handles updates to the AWS::AutoScaling::AutoScalingGroup orAWS::Lambda::Alias resource.

For more information on the DependsOn attribute, please visit the below URL-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
When a DependsOn attribute is required

VPC-gateway attachment

Some resources in a VPC require a gateway (either an Internet or VPN gateway). If your AWS CloudFormation template defines a VPC, a gateway,
and a gateway attachment, any resources that require the gateway are dependent on the gateway attachment. For example, an Amazon EC2

instance with a public IP address is dependent on the VPC-gateway attachment if the vec and InternetGateway resources are also declared in
the same template.

When creating a CloudFormation stack that will use a template to create a VPC, an Internet gateway and EC2 Instances with public IP address, there are several things that need to be considered to avoid running into errors in the template deployment.

A. Ensure that the parameter section is included in the template:

In a CloudFormation template, the parameters section allows users to input values at the time of stack creation, which makes the template more flexible and reusable. If this section is not included in the template, users will not be able to customize the resources that are created by the template. Therefore, it is important to ensure that the parameter section is included in the template to allow for flexibility.

B. Ensure that the DependsOn attribute is specified in the template:

The DependsOn attribute in CloudFormation allows you to specify dependencies between different resources in the template. This is important because some resources must be created before others can be created. If the DependsOn attribute is not specified in the template, it is possible that resources will be created in the wrong order, leading to errors and failed deployments. Therefore, it is important to ensure that the DependsOn attribute is specified in the template to avoid such errors.

C. Ensure that the DeletionPolicy is mentioned in the template:

In CloudFormation, the DeletionPolicy attribute allows you to specify what happens to a resource when it is deleted. If the DeletionPolicy is not specified in the template, the default behavior is to delete the resource and all of its associated data. This can be problematic if you want to preserve some of the data associated with the resource. Therefore, it is important to ensure that the DeletionPolicy is mentioned in the template to avoid accidental loss of important data.

D. Ensure that the UpdatePolicy is mentioned in the template:

The UpdatePolicy attribute in CloudFormation allows you to specify how a resource is updated when a change is made to the stack. If the UpdatePolicy is not specified in the template, the default behavior is to replace the entire resource with a new version. This can be problematic if you want to preserve some of the data associated with the resource. Therefore, it is important to ensure that the UpdatePolicy is mentioned in the template to avoid unexpected changes to resources.

In summary, when creating a CloudFormation stack that will use a template to create a VPC, an Internet gateway and EC2 Instances with public IP address, it is important to ensure that the template includes the parameter section for flexibility, the DependsOn attribute for specifying dependencies, the DeletionPolicy attribute for preserving important data, and the UpdatePolicy attribute for avoiding unexpected changes.