Change sets & safe updates

Preview a change before it happens.

Intermediate14 min · lesson 5 of 12

Applying an update blind is risky, because some property changes quietly replace a resource — a new database instance, a new bucket — rather than editing it in place. A change set is CloudFormation’s plan step: you submit the proposed template, CloudFormation computes exactly what it would do, and you review that diff — including which resources would be replaced — before choosing to execute it.

CHANGE SET: PLAN BEFORE EXECUTE
1Submit template
propose the updated template
2Create change set
CloudFormation computes the diff
3Review Replacement
spot resources destroyed & recreated
4Execute
apply only if the plan is intended
Replacement: True on a stateful resource means data loss - catch it here before executing.
terminal
$ aws cloudformation create-change-set \
--stack-name payments-network --change-set-name bump-size \
--template-body file://template.yaml
$ aws cloudformation describe-change-set \
--stack-name payments-network --change-set-name bump-size \
--query "Changes[].ResourceChange.[Action,LogicalResourceId,Replacement]" --output table
| Modify | AppServer | True | <- Replacement: True = destroy & recreate

Read the Replacement column

The critical field is Replacement. Action tells you Add/Modify/Remove; Replacement: True on a Modify means the resource will be destroyed and recreated to satisfy the change, because you altered an immutable property. On a stateless server that is fine; on an RDS instance or an EBS volume it is data loss and downtime. The change set is where you catch that before it happens, then execute only if the plan is what you intended.

terminal
$ aws cloudformation execute-change-set \
--stack-name payments-network --change-set-name bump-size
# only after you have read the diff and accepted the replacements
Replacement: True on stateful resources = data loss
Treat any Replacement: True on a database, volume, or bucket as a stop sign: the change will delete the existing resource and create a new one, losing its data. Plan those changes deliberately (snapshot, migrate, or use an update path that does not force replacement) rather than executing the change set as if it were an in-place edit.