Change Alarm Threshold in CloudFormation Template | AWS Exam DOP-C01

Change Alarm Threshold in CloudFormation Template

Prev Question Next Question

Question

You have a current Clouformation template defined in AWS.

You need to change the current alarm threshold defined in the Cloudwatch alarm.

How can you achieve this?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - C.

Option A is incorrect because CloudFormation templates have the option to update resources.

Option B is incorrect because only those resources that need to be changed as part of the stack update are actually updated.

Option D is incorrect because deleting the stack is not ideal when you already have a change option available.

When you need to make changes to a stack's settings or change its resources, you update the stack instead of deleting it and creating a new stack.

For example, if you have a stack with an EC2 instance, you can update the stack to change its AMI ID.When you update a stack, you submit changes, such as new input parameter values or an updated template.

AWS CloudFormation compares the changes you submit with the current state of your stack and updates only the changed resources.

For more information on stack updates, please refer to the below link:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html

To change the current alarm threshold defined in the CloudWatch alarm using CloudFormation template, you need to follow the below steps:

  1. Update the CloudFormation template: You need to update the existing CloudFormation template by modifying the section of the code that defines the alarm threshold. You can use a text editor or an integrated development environment (IDE) to edit the template file.

  2. Validate the CloudFormation template: After updating the CloudFormation template, you need to validate it before updating the stack. You can use the AWS Command Line Interface (CLI) or AWS Management Console to validate the template. The validation process ensures that the template is syntactically correct and adheres to the AWS CloudFormation standard.

  3. Update the CloudFormation stack: Once the template is validated, you can update the CloudFormation stack with the new template. During the update, CloudFormation compares the new template with the existing stack and makes the necessary changes to the resources in the stack.

There are two update options available in CloudFormation when updating a stack:

Option 1: Update the entire stack, including all resources, even those that have not changed in the new template. To perform this update, you can use the AWS CLI, AWS Management Console, or API.

Option 2: Update only the resources that have changed in the new template, without impacting other resources that have not changed. This update can be performed using the --stack-set-operation-type CHANGE_SET_REPLACE option in the AWS CLI or AWS Management Console.

Option 2 is generally preferred because it reduces the risk of unintended changes to the resources in the stack.

  1. Confirm the changes: After updating the stack, you need to confirm the changes by checking the CloudWatch alarm to ensure that the threshold has been updated as intended.

Therefore, the correct answer to this question is option B: "Update the template and then update the stack with the new template. Automatically all resources will be changed in the stack."