You use a CloudFormation stack to maintain a Launch Template and an Auto Scaling group.
The Auto Scaling group uses the latest version of the Launch Template.
One day, you modified the AMI ID of the Launch Template in the CloudFormation template and updated the CloudFormation stack.
However, new instances of the Auto Scaling group cannot start the web applications properly.
You figured out that there was a code issue in the new AMI and the AMI configuration should be rolled back.
Which of the following actions is the most appropriate?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer : D.
Option A is incorrect because the AMI ID is still wrong in the CloudFormation template so when the stack is updated, the AMI ID will be incorrect.
Option B is incorrect because the CloudFormation template does not correct the AMI ID of the Launch Template.
The Auto Scaling group does not need to be changed and should still use the latest version of the Launch Template.
This option is not the most appropriate one.
Option C is incorrect because the AMI ID should be corrected in the CloudFormation template.
It is inappropriate to modify the ASG configuration directly through the AWS console.
Option D is CORRECT because the Auto Scaling group uses the latest version of the Launch Template.
As the AMI ID is modified in the CloudFormation Template, the ASG will start using the previous AMI ID.Reference:
https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-launch-template-versions.htmlIn this scenario, the web application is not running properly due to a code issue in the new AMI. To resolve this issue, you need to roll back the AMI configuration to the previous version.
Option A: Use AWS CLI "aws ec2 delete-launch-template-versions" to delete the latest version and update the CloudFormation stack.
This option will delete the latest version of the Launch Template using AWS CLI and update the CloudFormation stack. However, this option does not guarantee that the previous version of the Launch Template will be used, as there may be more than one version of the Launch Template available. Additionally, deleting the latest version of the Launch Template may cause other issues if other resources are using it.
Option B: In the CloudFormation template, modify the Auto Scaling group to use the previous version of the Launch Template. Update the CloudFormation stack.
This option is the most appropriate in this scenario. You can modify the CloudFormation template to use the previous version of the Launch Template, update the CloudFormation stack, and roll back the AMI configuration. This will ensure that the previous version of the Launch Template is used and that the web application runs properly.
Option C: In the AWS EC2 console, modify the ASG to use the default version of the Launch Template. Update the CloudFormation stack.
This option is not the best solution because modifying the ASG to use the default version of the Launch Template does not guarantee that the previous version of the Launch Template will be used. Additionally, modifying resources outside of the CloudFormation stack may cause issues with stack updates in the future.
Option D: Change the AMI ID of the Launch Template to the previous one in the CloudFormation template and update the CloudFormation stack.
This option is similar to Option B, as it involves modifying the CloudFormation template to use the previous version of the Launch Template. However, instead of modifying the Auto Scaling group, you modify the Launch Template directly. This option is also appropriate in this scenario.
In summary, the most appropriate solution is to modify the CloudFormation template to use the previous version of the Launch Template and update the CloudFormation stack. This ensures that the previous version of the Launch Template is used and that the web application runs properly.