Learning center

UPDATE_ROLLBACK_FAILED in CloudFormation: find what can't roll back

UPDATE_ROLLBACK_FAILED means a resource could not return to its previous state, so read the failures after the rollback began, not the original one. Drift detection on that resource then separates a resource deleted or changed outside CloudFormation from one CloudFormation could not reach or restore.

What the state means#

A stack enters UPDATE_ROLLBACK_FAILED when an update fails and CloudFormation cannot roll back every change. The stack can't be updated in this state. You can continue the rollback, which returns the stack to UPDATE_ROLLBACK_COMPLETE so you can update it again, or delete the stack. ContinueUpdateRollback · Continue rolling back an update

Two failures are now on record: the one that started the rollback and the one that stopped it. The first explains why the update failed. Only the second explains why the stack is stuck, and it comes from one of four nearby causes:

  • The resource was deleted outside CloudFormation. CloudFormation still believes it exists and tries to restore it. AWS gives the example of a rollback to a database instance that someone deleted.
  • The resource was changed outside CloudFormation. Its live configuration no longer matches what CloudFormation recorded, so restoring the old configuration fails.
  • CloudFormation's credentials can't make the call. During a stack operation CloudFormation uses the stack's role, or, when the stack has none, a temporary session from the caller's credentials. A role that was deleted or narrowed since the last update can block the rollback.
  • The old configuration can't stabilize. An ECS service rolled back to a revision that can no longer start fails the same way the update did, so the stack moves from UPDATE_ROLLBACK_IN_PROGRESS to UPDATE_ROLLBACK_FAILED.

Stack role · Recovering stacks with ContinueUpdateRollback · ECS service stuck in an update

Find the failures after the rollback began#

Use a read-only profile and replace the uppercase placeholders. This query keeps the stack's own status changes and every failed resource event, in time order. Stack events

aws cloudformation describe-stack-events \
  --profile PROFILE --region REGION --stack-name STACK \
  --query 'reverse(StackEvents[?ResourceType==`"AWS::CloudFormation::Stack"` || ends_with(ResourceStatus, `"FAILED"`)])[].[Timestamp,LogicalResourceId,ResourceType,ResourceStatus,ResourceStatusReason]' \
  --output json --no-cli-pager

Find the stack's last UPDATE_ROLLBACK_IN_PROGRESS event. Failures before it belong to the forward update. The resources that went UPDATE_FAILED after it, before the stack reached UPDATE_ROLLBACK_FAILED, are the ones blocking you, and only those can later be skipped. A nested stack's failure appears in the parent as an AWS::CloudFormation::Stack resource; read the nested stack's own events for the resource inside it.

Then read the stack's role, so the permission case can be checked against the reasons:

aws cloudformation describe-stacks \
  --profile PROFILE --region REGION --stack-name STACK \
  --query 'Stacks[0].{status:StackStatus,reason:StackStatusReason,role:RoleARN,operations:LastOperations}' \
  --output json --no-cli-pager

Check the blocking resource for drift#

Drift detection compares a resource's live configuration with the template and parameters, and it runs on a stack in UPDATE_ROLLBACK_FAILED. detect-stack-resource-drift changes no resource; it records a drift result for the one you name. Drift detection · StackResourceDrift fields

aws cloudformation detect-stack-resource-drift \
  --profile PROFILE --region REGION --stack-name STACK --logical-resource-id LOGICAL_ID \
  --query 'StackResourceDrift.{status:StackResourceDriftStatus,reason:DriftStatusReason,differences:PropertyDifferences[].{path:PropertyPath,expected:ExpectedValue,actual:ActualValue,type:DifferenceType}}' \
  --output json --no-cli-pager

Drift checks only properties set explicitly in the template, and some resource types don't support it. Compare the result with the rollback failure's reason:

Drift statusRollback reasonMost likely causeWhat to change
DELETEDThe resource was not foundDeleted outside CloudFormationSkip the resource, then reconcile the template
MODIFIEDA conflict with the live configurationChanged outside CloudFormationRevert the property listed in differences by hand, then continue
IN_SYNCAn authorization failureThe stack role or caller can't make the callRestore the permission, or continue with a role that has it
IN_SYNCThe resource did not stabilizeThe old configuration can no longer runMake the old configuration runnable, or skip the resource
UNSUPPORTED or UNKNOWNAnyDrift can't tell youRead the resource through its own service

Continue the rollback#

Fix the cause first and continue without skipping anything. AWS recommends that order, and it leaves the stack consistent with its template. Continue rolling back an update · continue-update-rollback

# Change: resumes the rollback without skipping resources.
aws cloudformation continue-update-rollback \
  --profile PROFILE --region REGION --stack-name STACK --no-cli-pager

Pass --role-arn only to replace the stack's role: CloudFormation keeps using the role you pass for every later operation on the stack. Run the command on the parent stack, never on a nested stack.

When the cause can't be fixed, for example a resource that no longer exists, skip it. CloudFormation sets each skipped resource to UPDATE_COMPLETE and finishes the rollback. Afterwards the skipped resources no longer match the template. Reconcile the template or the resource before the next update; AWS warns that otherwise later updates can fail and the stack can become unrecoverable.

# Change: marks the named resources UPDATE_COMPLETE without rolling them back.
aws cloudformation continue-update-rollback \
  --profile PROFILE --region REGION --stack-name STACK \
  --resources-to-skip LOGICAL_ID NESTED_STACK_NAME.LOGICAL_ID --no-cli-pager

Skip the fewest resources you can. A dependent resource often fails only because the resource it depends on did, and skipping the root lets the dependent roll back normally. You can name only resources that are UPDATE_FAILED because their rollback failed. A resource inside a nested stack is named NestedStackName.ResourceLogicalID: the nested stack's own stack name, which CloudFormation usually generates with a random suffix, then the resource's logical ID inside it. AWS's worked example skips WebInfra-Storage.DB, not the parent's logical ID for that stack. The parent's AWS::CloudFormation::Stack resource reports the nested stack's ARN as its PhysicalResourceId, and the name is the part after stack/. --force-rollback skips every resource whose rollback failed, nested stacks included, and can't be combined with --resources-to-skip. Drift detection then reports skipped resources as NOT_CHECKED. ContinueUpdateRollback parameters · Nested stacks hierarchy example

Confirm the result in the events: the stack reaches UPDATE_ROLLBACK_COMPLETE. Before the next update, run drift detection on the stack and compare each skipped resource with the template.

An illustrative rollback#

This fixture is fictional. Stack checkout-prod updates CheckoutService from checkout:41 to checkout:42. The update fails at 14:20 because the service does not stabilize, and the stack begins UPDATE_ROLLBACK_IN_PROGRESS.

In the first outcome, CheckoutQueue (AWS::SQS::Queue) goes UPDATE_FAILED at 14:22 with a reason saying the queue does not exist, and drift returns DELETED. Someone removed the queue by hand during the incident. Nothing can restore the old queue in place, so skip CheckoutQueue, let the rollback finish, then decide in the template whether the queue should exist and update the stack to match.

In the second outcome, CheckoutService itself goes UPDATE_FAILED again at 16:58 and drift returns IN_SYNC. The rollback set the service back to checkout:41, and those tasks stop too: their stopped reason names a secret version that was removed after checkout:41 was registered. Skipping would leave the stack believing the service runs checkout:41 while ECS keeps failing. Restore the secret reference so checkout:41 can start, then continue without skipping. For the update-side signature, see why the ECS service did not stabilize.

Where this read misleads#

The first failed event in the history is often the forward update's failure, and fixing it does not unblock the rollback. Keep to the events after UPDATE_ROLLBACK_IN_PROGRESS. Compare with the other deploy records in the signature table.

IN_SYNC does not mean the resource is fine. Drift covers only properties set in the template, so a change to a property the template leaves at its default is invisible. A resource whose type does not support drift returns no answer at all.

Skipping trades a stuck stack for a stack whose record is wrong. The next update that touches a skipped resource starts from CloudFormation's record, and AWS warns that such updates can fail. If the next update fails because a property change would replace a resource with a fixed name, that is a different read: check the change set for replacement.

Questions#

Can I update a CloudFormation stack in UPDATE_ROLLBACK_FAILED?

No. Continue the rollback to reach UPDATE_ROLLBACK_COMPLETE, then update the stack, or delete it.

Which resources can I pass to --resources-to-skip?

Only resources in UPDATE_FAILED because their rollback failed, not ones that failed during the forward update or were cancelled. Name a resource in a nested stack as NestedStackName.ResourceLogicalID, using the nested stack's stack name, such as checkout-prod-DataStack-1A2B3C4D, not its logical ID in the parent.

What happens to a resource I skip during continue-update-rollback?

CloudFormation marks it UPDATE_COMPLETE without changing it, so its recorded state no longer matches the template. Update the template or the resource so they agree before the next stack update.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading