Open adeeb-ma opened 10 months ago
Voting for Prioritization
Volunteering to Work on This Issue
Yeh this is a bug in the provider.
When triggering an instance refresh, Terraform should not modify the Auto Scaling Group before calling StartInstanceRefresh
. Instead it should pass
DesiredConfiguration:
LaunchTemplate:
LaunchTemplateName: <name>
Version: <version>
to the StartInstanceRefresh
call.
Then the instance refresh will update the ASG to point to the new Launch Template Version IF and only IF the instance refresh succeeded. If it fails; it will use the existing Launch Template Version set on the ASG for the rollback.
If you update the launch template version manually beforehand; this confuses any of the rollback logic.
In short: The terraform provider should never manually update the launch template parameters on the ASG. Instead it should pass DesiredConfiguration
to StartInstanceRefresh
The same has to happen for changing mixed_instances_policy
.
In that case DesiredConfiguration.MixedInstancesPolicy
should be set with the fields that need updating.
Terraform Core Version
1.0.5
AWS Provider Version
5.32.1
Affected Resource(s)
aws_autoscaling_group
Expected Behavior
Applying the Autoscaling group with Instance Refresh enabled (i.e. changing launch template version, for example) would trigger the instance refresh to deploy the new configurations, but shouldn't update the configuration beforehand.
In the AWS console, you would see under the "details" tab the old Launch Template Version, while in the Instance Refresh tag it would run with the target configuration being the newer launch template version.
This would imply that in case the new launch template version (2) fails on healthcheck for a while, it would rollback to the previous version (1).
Actual Behavior
Running apply would update the launch template version for the ASG, AND THEN triggers instance refresh with target configuration being the latest launch template version.
This imposes that should the newer launch template version (2) fail on healthcheck for a while, it would "roll back" to the same newer launch template version (2), making the ASG stuck in a perpetual rollback replacing the unhealthy launch template over and over.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
If the new template is unhealthy, you should also see that the instance refresh would fail after an hour, but the rollback would launch the Newer Launch Template Version (2) forever.
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
No