What's Actually Happening

AWS CDK deployment fails. Stack cannot be created or updated, blocking infrastructure changes.

The Error You'll See

```bash $ cdk deploy

MyStack: 12:15:30 PM - CREATE_FAILED Template format error: Resource name is invalid ```

Why This Happens

  1. 1.Stack configuration error
  2. 2.Resource quota exceeded
  3. 3.IAM permission denied
  4. 4.Resource already exists
  5. 5.Circular dependency

Step 1: Check CloudFormation Events

bash
aws cloudformation describe-stack-events --stack-name my-stack
aws cloudformation describe-stack-resources --stack-name my-stack

Step 2: Check CDK Synth

bash
cdk synth
cat cdk.out/MyStack.template.json

Step 3: Check Stack Status

bash
aws cloudformation describe-stacks --stack-name my-stack
cdk ls

Step 4: Check IAM Permissions

bash
aws iam get-user
aws sts get-caller-identity
# Ensure user has required permissions

Step 5: Check Service Quotas

bash
aws service-quotas get-service-quota --service-code ec2 --quota-code L-12345

Step 6: Review Stack Outputs

bash
cdk diff
aws cloudformation get-template --stack-name my-stack

Step 7: Check Bootstrap

bash
cdk bootstrap
cdk bootstrap aws://account-id/region

Step 8: Rollback Failed Stack

bash
aws cloudformation rollback-stack --stack-name my-stack
cdk destroy my-stack

Step 9: Enable Termination Protection

bash
aws cloudformation update-termination-protection --stack-name my-stack --enable-termination-protection

Step 10: Monitor Deployment

bash
watch -n 10 'aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].StackStatus"'
  • [Fix CloudFormation Stack Failed](/articles/fix-cloudformation-stack-failed)
  • [Fix Terraform State Locked](/articles/fix-terraform-state-locked)