Updraft ExtensionsPreview

Update behaviour

What CloudFormation actually does to a running resource when you change a property — and why “Replacement” deserves to be red.

The four behaviours #

Every property in this reference carries one of four update behaviours. They describe what happens to the existing resource when only that property changes.

BehaviourPhysical IDAvailabilityData
No interruptionUnchangedContinuousUntouched
Some interruptionUnchangedBrief gapEphemeral storage may be lost
ReplacementNewDepends on orderingEverything not persisted elsewhere is lost
Not applicable——The property cannot change in isolation

How replacement actually runs #

This is the part that determines whether a replacement is survivable.

The default order. The old resource is deleted only after the new one reports CREATE_COMPLETE — but CREATE_COMPLETE means the API call returned, not that the resource is ready to serve.

Create-only properties #

A property marked create-only can be set at creation and never changed. Changing it in a template is not an error — it is a request to replace the resource, and CloudFormation will do exactly that.

The two are usually the same property. BucketName, RoleName, ImageId and SubnetId are all create-only and all cause replacement, because the underlying API has no way to change them on an existing resource.

Reading a change set before you trust it #

The single most useful habit around update behaviour:

aws cloudformation create-change-set \
  --stack-name payments-production \
  --change-set-name review \
  --template-body file://template.yaml \
  --capabilities CAPABILITY_IAM

aws cloudformation describe-change-set \
  --stack-name payments-production \
  --change-set-name review \
  --query 'Changes[?ResourceChange.Replacement==`True`].ResourceChange.{Id:LogicalResourceId,Type:ResourceType,Because:Scope}' \
  --output table

Deletion policies #

Two policies govern what happens to a resource CloudFormation wants to remove, and the distinction between them is the one people miss.

PolicyApplies when
DeletionPolicyThe stack is deleted, or the resource is removed from the template.
UpdateReplacePolicyThe resource is replaced during an update.