Auto Scaling group rollout rolls back and leaves instances InService=false after lifecycle-hook timeout during deployment
Environment
Production AWS environment: ECS on EC2-backed Auto Scaling Group with CodeDeploy blue/green deployment. Lifecycle hook configured to run a bootstrap script that registers instance with internal monitoring and pulls secrets from SSM Parameter Store; deployments started after a recent pipeline change.
Symptoms
During a deployment, ASG launches new instances but instances remain in Terminating:Wait with lifecycle hook active; CodeDeploy times out waiting for healthy targets and marks rollout failed, then ASG scales down leaving capacity short. New instances do not transition to InService state and do not receive traffic. Problem began after adding a step in bootstrap to fetch secrets over a custom VPC endpoint.
Observations
CloudWatch logs show lifecycle hook transition stuck with no completion message. EC2 instance console output shows bootstrap script hanging on curl to the VPC endpoint DNS name; the networking appears to resolve but connection stalls. IAM role permissions for SSM and CodeDeploy are unchanged. The lifecycle hook timeout is the default 3600s; changing it reduces frequency of automatic rollback but does not solve root cause. Rolling back pipeline change to previous bootstrap script resolves the launches instantly.
Already attempted
Disabled the new secret-fetch step — instances proceed and enter InService. Increased lifecycle hook timeout to 7200s as a temporary mitigation. Added retries in bootstrap script and explicit timeouts for network calls. Enabled boot logging to S3 for deeper debugging. Created a minimal test ASG with same launch template — reproduced the hang only when the custom VPC endpoint was referenced.
Question
What diagnostics should be run to determine whether the lifecycle-hook boot hang is due to VPC endpoint DNS/resolution, route table/NACL blocking, or a missing VPC Endpoint policy? What safe, reversible deployment changes will prevent Auto Scaling from rolling back while preserving secret retrieval security?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags