So let's say previous to launch I have 1 version of the launch template resource. After the launch, a new launch template resource gets created. Now let's say CloudFormation rolls back due to some error hit in the ASG. My expectation is that the launch template that was created during the deployment is deleted on rollback.
Now the latest version of the launch template after rollback is version 2.
I find this to be a gotcha if you have a CloudFormation template where you might manage multiple ASGs and LTs or if you want to revert the code for your LT to what you expect is currently deployed so your next update doesn't try to replace your ASG but instead your ASG will attempt to be replaced.
Expected Behavior
During rollback I expect the new launch template to be deleted and the latest version to be the version which was latest previous to deployment
Observed Behavior
Latest launch template does not get deleted by CloudFormation upon rollback
Test Cases
Launch a very simple cloudformation template with a dead simple launch template and asg. Let that succeed. Now update the launch template such that CFN will create a new one (say with a new valid AMI) and also update the ASG to ensure the cfn stack fails (add "exit 1" in the userdata somewhere). Upon rollback your launch template's latest version should be 1. It will instead be 2.
Name of the resource
AWS::EC2::LaunchTemplate
Resource Name
No response
Issue Description
Sample CFN with one ASG and one LT:
So let's say previous to launch I have 1 version of the launch template resource. After the launch, a new launch template resource gets created. Now let's say CloudFormation rolls back due to some error hit in the ASG. My expectation is that the launch template that was created during the deployment is deleted on rollback.
Now the latest version of the launch template after rollback is version 2.
I find this to be a gotcha if you have a CloudFormation template where you might manage multiple ASGs and LTs or if you want to revert the code for your LT to what you expect is currently deployed so your next update doesn't try to replace your ASG but instead your ASG will attempt to be replaced.
Expected Behavior
During rollback I expect the new launch template to be deleted and the latest version to be the version which was latest previous to deployment
Observed Behavior
Latest launch template does not get deleted by CloudFormation upon rollback
Test Cases
Launch a very simple cloudformation template with a dead simple launch template and asg. Let that succeed. Now update the launch template such that CFN will create a new one (say with a new valid AMI) and also update the ASG to ensure the cfn stack fails (add "exit 1" in the userdata somewhere). Upon rollback your launch template's latest version should be 1. It will instead be 2.
Other Details
No response