Two kinds of failure in the same field#
EC2 Auto Scaling records the reason for a failed launch in the scaling activity's StatusMessage, with StatusCode Failed. AWS's troubleshooting pages list the messages that point at the launch template itself. Activity fields · Instance launch failures · AMI issues
| Message begins with | Setting in the new version | AWS's stated cause |
|---|---|---|
The AMI ID <ID of your AMI> does not exist. | ImageId | The AMI was deleted after the template was created |
AMI <AMI ID> is pending, and cannot be run. | ImageId | The AMI is not available yet |
| An architecture mismatch between the instance type and the AMI manifest | ImageId or InstanceType | The type's architecture does not match the image |
The security group <name of the security group> does not exist. | SecurityGroupIds or network interface groups | The group was deleted |
The key pair <key pair associated with your EC2 instance> does not exist. | KeyName | The key pair was deleted |
Invalid device name <device name> | BlockDeviceMappings | A device name is unavailable or conflicts with the AMI |
The requested configuration is currently not supported. | Several | An option does not fit the type, Region or zone |
Client.InternalError: Client error on launch. | Encrypted volumes | The service-linked role cannot use the KMS key; see the KMS guide |
Capacity messages are different in kind. We currently do not have sufficient <instance type> capacity in the Availability Zone you requested names a zone and clears when capacity returns; the capacity guide covers that branch. AWS may reword any of these messages, so match on the leading phrase and keep the full text.
Some template problems never reach a launch. AWS validates template values when you create or update a group that uses the template, and rejects the update with You must use a valid fully-formed launch template or You are not authorized to use launch template. The second covers missing ec2:RunInstances or ec2:CreateTags for the caller, a missing iam:PassRole for the template's instance profile, and a private AMI in another account that is not shared with yours. A group whose version is $Latest or $Default takes the new version at launch time without an update, so it skips that validation and the first sign is a failed launch. Launch template troubleshooting · LaunchTemplateSpecification
Read the failures and the version being launched#
Use a read-only profile and replace the uppercase placeholders. Collect the failed activities first, then read which template version the group launches. describe-scaling-activities
aws autoscaling describe-scaling-activities \
--profile PROFILE --region REGION --auto-scaling-group-name GROUP \
--filters Name=Status,Values=Failed \
--query 'Activities[].{start:StartTime,message:StatusMessage,details:Details}' \
--output json --no-cli-pager
aws autoscaling describe-auto-scaling-groups \
--profile PROFILE --region REGION --auto-scaling-group-names GROUP \
--query 'AutoScalingGroups[0].{template:LaunchTemplate,mixedTemplate:MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification,overrides:MixedInstancesPolicy.LaunchTemplate.Overrides[].{type:InstanceType,requirements:InstanceRequirements,template:LaunchTemplateSpecification},instances:Instances[].{id:InstanceId,zone:AvailabilityZone,type:InstanceType,template:LaunchTemplate.LaunchTemplateId,version:LaunchTemplate.Version,state:LifecycleState}}' \
--output json --no-cli-pager
overrides lists the group's instance types; one that carries its own template launches from that template, so compare that template's versions for its types. Details carries the zone of each attempt. If the failures span every zone the group uses and repeat one message, the version is the lead. During an instance refresh the version being rolled out is the refresh's desired configuration, which the group adopts only after the refresh succeeds; read it with describe-instance-refreshes as shown in the refresh guide. Instance refresh concepts
If the group's version is $Latest or $Default, resolve it to a number. The lookup returns what the alias points at now, which can be a later version than the one that failed:
aws ec2 describe-launch-template-versions \
--profile PROFILE --region REGION --launch-template-id TEMPLATE_ID \
--versions '$Latest' '$Default' \
--query 'LaunchTemplateVersions[].{version:VersionNumber,default:DefaultVersion,created:CreateTime,by:CreatedBy}' \
--output json --no-cli-pager
Compare the resolved version's CreateTime with the failed activity's StartTime. A $Latest version created after the failure did not fail; the failed launch used the newest version created before it. $Default can move without a new version, and the version list keeps no history of the pointer, so read the ModifyLaunchTemplate events in CloudTrail for the time of the failure. When neither settles it, treat the failed version as unknown and diff the versions on each side of the failure. LaunchTemplateVersion · ModifyLaunchTemplate
Diff the old and new versions#
Pass the last version that launched and the one that fails. The query leaves out UserData, which the API marks as sensitive; compare it separately if the release changed the bootstrap. describe-launch-template-versions · LaunchTemplateVersion
aws ec2 describe-launch-template-versions \
--profile PROFILE --region REGION --launch-template-id TEMPLATE_ID \
--versions OLD_VERSION NEW_VERSION \
--query 'LaunchTemplateVersions[].{version:VersionNumber,by:CreatedBy,image:LaunchTemplateData.ImageId,type:LaunchTemplateData.InstanceType,requirements:LaunchTemplateData.InstanceRequirements,key:LaunchTemplateData.KeyName,profile:LaunchTemplateData.IamInstanceProfile,groups:LaunchTemplateData.SecurityGroupIds,interfaces:LaunchTemplateData.NetworkInterfaces[].{groups:Groups,subnet:SubnetId},volumes:LaunchTemplateData.BlockDeviceMappings}' \
--output json --no-cli-pager
Check each field that changed against the message. For a new AMI, look it up from the group's account. describe-images returns images you own, public images and images another account explicitly shares with you, so an empty result or an InvalidAMIID.NotFound error means the image is not launchable from this account, whether it was deregistered or never shared. An UnauthorizedOperation error only says your profile cannot call describe-images; fix the profile before drawing a conclusion about the AMI. A State other than available matches the pending message. Compare Architecture with the instance type's supported architectures. describe-images · DescribeImages
aws ec2 describe-images \
--profile PROFILE --region REGION --image-ids AMI_ID \
--query 'Images[].{id:ImageId,state:State,owner:OwnerId,arch:Architecture}' \
--output json --no-cli-pager
aws ec2 describe-instance-types \
--profile PROFILE --region REGION --instance-types INSTANCE_TYPE \
--query 'InstanceTypes[].{type:InstanceType,arch:ProcessorInfo.SupportedArchitectures}' \
--output json --no-cli-pager
aws ec2 describe-security-groups \
--profile PROFILE --region REGION --group-ids SG_ID_1 SG_ID_2 \
--query 'SecurityGroups[].{id:GroupId,name:GroupName,vpc:VpcId}' \
--output json --no-cli-pager
AWS's own suggestion for a template it cannot explain is a dry run, which checks the request without launching an instance. It runs with your credentials, so it tests the template's values and your permissions, not the group's service-linked role. Launch template troubleshooting · run-instances
# Dry run: validates the request, launches nothing.
aws ec2 run-instances \
--profile PROFILE --region REGION \
--launch-template LaunchTemplateId=TEMPLATE_ID,Version=NEW_VERSION --dry-run
What the reads establish#
| Failures | Diff | Reading |
|---|---|---|
| Same template message in every zone | The matching field changed | The new version; fix that field |
| Same template message in every zone | Nothing relevant changed | A referenced resource changed outside the template, such as a deleted AMI or security group |
| Capacity message in one zone | InstanceType and InstanceRequirements unchanged | Capacity, not the version |
| Capacity message in one zone | InstanceType or InstanceRequirements changed | The new version selects different types, and the one it chose is short in that zone; the old version's types may still launch |
Client.InternalError: Client error on launch. | A volume, snapshot or AMI changed | A KMS key the service-linked role cannot use |
The second row matters during a rollback. If the AMI or security group was deleted, the old version fails the same way, and rolling back the template does not restore launches. The fourth is the reverse: rolling back restores the old type, which draws on a different capacity pool, though adding the type to the group's instance types keeps the new version's other changes.
Two fictional outcomes#
The group orders-asg moves from orders-lt version 7 to version 8 by updating the group to version 8. The diff shows one change: version 8 uses security group sg-0bbb2222 instead of sg-0aaa1111.
In the first outcome every launch fails, in all three zones, with The security group message naming sg-0bbb2222. describe-security-groups returns an error for that ID: the group was deleted in a network cleanup after version 8 was written. Version 7 still references a group that exists, so updating the group back to version 7 restores launches, and version 9 can carry the security group the release intended.
In the second outcome, launches of version 8 succeed in us-east-1a and us-east-1b and fail only in us-east-1c with the capacity message. Version 8 kept version 7's instance type, so version 7 would hit the same shortage. Version 8 is working; the zone is short of capacity, and the fix is in the group's instance types and zones, not the template.
Fix and confirm#
Create a new version with the corrected reference and point the group at its number, or roll back to the last working number. AWS documents the instance refresh rollback as unavailable when the group uses $Latest or $Default, and a numbered version makes the next change go through the group update, where AWS validates it. Confirm on the replacements: Successful launch activities in each zone, and every new instance showing the template ID and new number that apply to it, which for an override with its own template is that template's. Undo changes with a rollback
Where this reading stops#
A launch that succeeds only proves the instance started. A version whose user data fails, or whose application never answers its health check, launches cleanly and is replaced later: see health check replacement. A dry run that passes for you does not show the group can launch, because the group launches through its service-linked role. Scaling activities are kept for six weeks; for the signature table across services, see the collection hub.
Bring the template change into code review#
Template versions usually come from infrastructure code. Put the version diff and the failing activity message in the pull request that fixes it, so a reviewer can check the new AMI, security group and device mappings against the evidence. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. Start a free GitHub review · Eligibility and fair-use terms · Current product availability
Questions#
How do I tell a broken launch template from an EC2 capacity problem?
Read the failed activities' messages and zones. A template error repeats one message in every zone and names a setting such as the AMI or a security group; a capacity error names one zone and an instance type. A capacity error after a change of instance type can still be the version's doing, because the old type draws on another pool.
Why did updating the Auto Scaling group not catch the bad launch template version?
AWS validates template values when you create or update a group. A group set to $Latest or $Default takes a new version at launch time without an update, so the first sign of a bad version is a failed launch.
Will rolling back to the previous launch template version fix the failures?
Only if the old version's references still exist. If an AMI or security group was deleted outside the template, the old version fails with the same message, so check each referenced resource before rolling back. For a capacity error, a rollback helps only when it brings back a different instance type.