0
0
AWScloud~10 mins

Updating and deleting stacks in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Updating and deleting stacks
Create or have existing stack
Decide to update stack?
NoExit
Yes
Prepare updated template or parameters
Submit update request
CloudFormation processes update
Update success?
NoRollback changes
Yes
Stack updated
Decide to delete stack?
NoExit
Yes
Submit delete request
CloudFormation deletes resources
Stack deleted
End
This flow shows how you update an existing stack by submitting changes, then optionally delete the stack to remove all resources.
Execution Sample
AWS
aws cloudformation update-stack --stack-name MyStack --template-body file://update.yaml
aws cloudformation delete-stack --stack-name MyStack
Update a stack named MyStack with a new template, then delete the stack.
Process Table
StepActionInputCloudFormation BehaviorResult
1Check if stack existsStack: MyStackStack foundReady for update
2Submit update requestTemplate: update.yamlValidates template, compares changesUpdate in progress
3Process updateChanges detectedUpdates resources as neededResources updated
4Update success?Update statusYesStack updated successfully
5Decide to delete stackUser input: YesAccept delete requestDelete in progress
6Process deleteDelete stack MyStackDeletes all stack resourcesStack deleted
7Check stack existenceStack: MyStackStack not foundEnd - stack removed
💡 Stack is deleted, no longer exists in CloudFormation
Status Tracker
VariableStartAfter Step 2After Step 4After Step 6Final
Stack StatusCREATE_COMPLETEUPDATE_IN_PROGRESSUPDATE_COMPLETEDELETE_COMPLETEDELETE_COMPLETE (stack removed)
Key Moments - 3 Insights
Why does the stack status change to UPDATE_IN_PROGRESS after submitting an update?
Because CloudFormation starts applying the changes, as shown in execution_table step 2 and 3, the status reflects the ongoing update process.
What happens if the update fails during processing?
CloudFormation rolls back to the previous stable state, preventing partial updates. This is implied in the flow after step 3 if update success is No.
Does deleting a stack remove all its resources automatically?
Yes, as shown in execution_table step 6, deleting the stack triggers deletion of all resources created by that stack.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the stack status after step 4?
ACREATE_COMPLETE
BDELETE_IN_PROGRESS
CUPDATE_COMPLETE
DUPDATE_IN_PROGRESS
💡 Hint
Check the 'Stack Status' variable in variable_tracker after step 4
At which step does CloudFormation start deleting the stack resources?
AStep 4
BStep 6
CStep 5
DStep 7
💡 Hint
Refer to execution_table row where 'Process delete' action happens
If the update fails during processing, what would happen in the execution flow?
ACloudFormation rolls back to previous stack state
BStack is deleted immediately
CStack status changes to DELETE_IN_PROGRESS
DUpdate completes successfully
💡 Hint
See key_moments explanation about update failure and rollback
Concept Snapshot
Updating and deleting stacks in AWS CloudFormation:
- Update stack by submitting new template or parameters
- CloudFormation validates and applies changes
- If update fails, rollback restores previous state
- Delete stack to remove all resources
- Stack status shows progress (UPDATE_IN_PROGRESS, DELETE_IN_PROGRESS, etc.)
Full Transcript
This visual execution shows how AWS CloudFormation updates and deletes stacks. First, you check if the stack exists. Then you submit an update with a new template. CloudFormation validates and applies the update, changing the stack status to UPDATE_IN_PROGRESS and then UPDATE_COMPLETE if successful. If the update fails, it rolls back to the previous state. After updating, you can delete the stack, which triggers deletion of all resources and removes the stack from CloudFormation. The stack status changes accordingly during these steps, helping track progress.