What happens when a CloudFormation stack creation fails?

Beginner

Answer

When stack creation fails:

  1. Automatic Rollback: CloudFormation automatically deletes all successfully created resources
  2. Stack State: Stack goes to ROLLBACK_COMPLETE state
  3. Error Information: Detailed error messages available in Events tab
  4. Billing: You're only charged for resources that existed during the failed creation period
    Prevention strategies:
  • Validate templates before deployment
  • Use --disable-rollback flag only for debugging
  • Implement proper IAM permissions
  • Check service limits and quotas
  • Use change sets for updates
    Example debugging:
aws cloudformation describe-stack-events --stack-name my-stack