What You'll Learn
You'll understand how CloudFormation stacks move through creation, updates, and deletion, and what happens when things go wrong.
Understanding Stack Lifecycle
A CloudFormation stack is a living entity with distinct lifecycle phases. Think of it like constructing a building: you lay the foundation, add floors, make renovations, and eventually demolish it if needed.
Stack States
When you create or modify a stack, it transitions through various states:
- CREATE_IN_PROGRESS: CloudFormation is provisioning resources
- CREATE_COMPLETE: All resources successfully created
- CREATE_FAILED: Creation failed; stack may be rolled back
- UPDATE_IN_PROGRESS: Modifying existing resources
- UPDATE_COMPLETE: Update succeeded
- DELETE_IN_PROGRESS: Tearing down resources
- DELETE_COMPLETE: Stack fully removed
- ROLLBACK_IN_PROGRESS: Undoing failed changes
Creation Process
When you submit a template, CloudFormation:
- Validates the template syntax
- Determines resource dependencies
- Creates resources in the correct order
- Waits for each resource to reach a stable state
If any resource fails, CloudFormation automatically rolls back by deleting successfully created resources, returning to the previous stable state.
Update Behavior
Updates follow a similar pattern but preserve existing resources when possible. CloudFormation determines whether each resource needs replacement, modification, or no change.
Deletion Process
During deletion, CloudFormation removes resources in reverse dependency order. Resources with DeletionPolicy: Retain survive stack deletion (like keeping photos before demolishing a house).
Rollback Scenarios
Rollbacks protect you from partial failures. If creation fails, you typically get CREATE_FAILED → ROLLBACK_IN_PROGRESS → ROLLBACK_COMPLETE. For updates: UPDATE_ROLLBACK_IN_PROGRESS → UPDATE_ROLLBACK_COMPLETE.
Key Takeaway: CloudFormation stacks have predictable lifecycles with automatic rollback protection—failed operations won't leave you with half-built infrastructure orphaned in your account.