A new instance goes `pending` → `terminated` within seconds with state reason `Client.InternalError: Client error on launch`.
IntermediateTroubleshootingEC2, Auto Scaling and Load Balancing
Answer
Likely causes → Usually the EBS volumes are encrypted with a customer managed KMS key that the launching principal (or the ASG service-linked role) cannot use. It can also mean a snapshot is missing or the volume limit was exceeded.
Diagnose →
aws ec2 describe-instances --instance-ids i-0abc --query 'Reservations[].Instances[].StateReason'
aws ec2 describe-images --image-ids ami-0abc --query 'Images[].BlockDeviceMappings[].Ebs'
aws kms get-key-policy --key-id <key-id> --policy-name default
Fix →
- Allow the launching principal and
AWSServiceRoleForAutoScalingto use the key:kms:CreateGrant,kms:Decrypt,kms:GenerateDataKeyWithoutPlaintext,kms:ReEncrypt*andkms:DescribeKey - For cross-account AMIs, update the key policy in the owning account and create a grant for the service-linked role
Prevent → Keep a tested key-policy template for EBS keys that names the ASG service-linked role.