Repository navigation
Description
Summary
When a resource in a stack fails, substrate records the failure on that resource
and carries on deploying the rest of the template. The stack reaches
CREATE_COMPLETE. Real CloudFormation rolls the stack back and reports
ROLLBACK_COMPLETE, leaving none of the template's resources behind.
aws cloudformation create-stack --stack-name partial \
--template-body '{"Resources":{
"Refused":{"Type":"AWS::S3::Bucket","Properties":{"BucketName":"no"}},
"After":{"Type":"AWS::SQS::Queue","Properties":{"QueueName":"still-here"}}}}'
aws cloudformation describe-stacks --stack-name partial
# StackStatus: CREATE_COMPLETE (real CFN: ROLLBACK_COMPLETE)
aws sqs get-queue-url --queue-name still-here
# found (real CFN: rolled back, absent)
This became observable for the first time in v0.87.1, which is what makes it worth
filing: before #519, a refused S3 or IAM resource recorded no failure at all, so
there was nothing for a rollback to key off.
Why it was deliberately left out of v0.87.1
Rollback is a much larger behaviour than the status check that exposed it. It needs
the delete dispatcher from #518 (a rollback deletes what was created so far, in
reverse order, honouring DeletionPolicy), a stack-level decision about
OnFailure (DO_NOTHING / ROLLBACK / DELETE), the ROLLBACK_IN_PROGRESS and
ROLLBACK_FAILED states, and DisableRollback. Bundling it into a patch release
that fixes tag expansion would have been unrelated scope creep.
Acceptance criteria
- A resource failure during
CreateStackrolls back the resources already
created, in reverse order, and the stack reportsROLLBACK_COMPLETE. -
OnFailure=DO_NOTHINGleaves the stack inCREATE_FAILEDwith the
resources in place — the current behaviour, now selectable rather than
implicit. -
OnFailure=DELETEdeletes the stack entirely. -
DisableRollback=trueis honoured, and--no-disable-rollbacklikewise. - An
UpdateStackfailure rolls back to the previous template
(UPDATE_ROLLBACK_COMPLETE), which is a distinct path from create rollback. - A rollback that cannot delete a resource reports
ROLLBACK_FAILEDrather
than claiming success. -
docs/services.mdreplaces the "substrate does not roll back" paragraph. - Depends on CloudFormation: DeleteStack does not delete the stack's resources #518 for the delete dispatcher.
Provenance
Current behaviour is pinned by TestCFN_FailedResourceDoesNotStopTheStack in
emulator/betty_cfn_failure_test.go, added in v0.87.1 so the difference from real
CloudFormation is a recorded decision rather than an oversight. Rollback semantics
and the OnFailure values are from the CloudFormation CreateStack API reference
and the stack-failure-options documentation.
Activity
scttfrdmn commentedon Aug 3, 2026
Milestoned to v0.89.0, where its blocker #518 also lands. Keeping the
status: blockedlabel until that dispatcher exists.Why it cannot come earlier. Rollback is deletion, in reverse:
ROLLBACK_IN_PROGRESSmeans deleting the resources created so far, in reverse creation order. Substrate cannot delete a stack's resources at all today (#518), so there is nothing to roll back with. The two share the same machinery, and #518 supplies the ordering for free —typePriorityreversed.What v0.87.1 changed here — it made this issue reachable, which it was not before. #519 fixed the deployer swallowing every S3 and IAM resource failure: those plugins return a 4xx response with a nil error, and only the
*AWSErrorconvention was inspected, so a refused bucket or role was recorded asCREATE_COMPLETE. A resource that genuinely fails now reportsCREATE_FAILED. That means the precondition for a rollback — a visibly failed resource in a stack — now actually occurs, where before v0.87.1 it was invisible for two of the most commonly-declared services. The v0.87.1 changelog says this explicitly: substrate still does not roll back, and points here.So the consumer-visible situation today is the worst intermediate state: a stack reports
CREATE_FAILEDon a resource, keeps the resources it already created, and reports a stack status that does not reflect the failure. Half-built stacks are now observable and there is no way to unwind them.Design decisions to settle when it lands (recording them now so they are not rediscovered):
OnFailure(DO_NOTHING/ROLLBACK/DELETE) andDisableRollbackonCreateStack, which are mutually exclusive;ROLLBACK_IN_PROGRESS→ROLLBACK_COMPLETE/ROLLBACK_FAILED; and the distinct update path, where a failedUpdateStackgoesUPDATE_ROLLBACK_IN_PROGRESS→UPDATE_ROLLBACK_COMPLETEand must restore the previous property values rather than delete the resource — a different operation from create-rollback, and the one most likely to be missed.DeletionPolicy: Retain(added tocfnResourceas part of #518) must be honoured during rollback too.scttfrdmn commentedon Aug 3, 2026
Shipped in v0.89.0 via #547. Every acceptance criterion is met and verified end to end against a live server; each is pinned by a test.
ROLLBACK_COMPLETE, reusing CloudFormation: DeleteStack does not delete the stack's resources #518's sweep.OnFailure=DO_NOTHING→CREATE_FAILEDwith resources in place;OnFailure=DELETEremoves the stack;DisableRollback=truehonoured and reported back byDescribeStacks.OnFailureandDisableRollbacktogether is aValidationError, tested by presence rather than value — the CLI's--no-disable-rollbacksends an explicitfalse, so a value test would accept a combination the API rejects. Measured against the CLI.ROLLBACK_FAILED, and the stack keeps its record so the undeleted resource is discoverable.UpdateStack→UPDATE_ROLLBACK_COMPLETE, documented as an approximation:UpdateStackis a re-Deploy, so the rollback re-deploys the stored previous template and converges on its declared state rather than restoring properties field by field.docs/services.md's "the stack itself still reaches a terminalCREATE_COMPLETE… rollback is not modelled" paragraph is replaced.Two things worth recording beyond the issue as filed.
A second defect, found while building this.
UpdateStackis a re-Deployof the whole template, so every unchanged resource's create is re-issued and its plugin refuses it as already existing — where real CloudFormation issues no call at all for a resource it is not changing. Before rollback that was merely invisible (the refusal landed on the resource's error field and the stack still saidUPDATE_COMPLETE); with rollback added it becomes data loss, since every update would see failures and sweep the resources it was asked to keep. An already-exists refusal is now cleared only when the previous deployment created that logical ID successfully and the template still declares it identically. A rename into another stack's name, a resource that failed previously, and a record from another account or Region all remain real failures.Ordering. The export-conflict checks run before the failure branch, because a duplicate export name is a refusal of the request — a request substrate declines outright never became a stack whose resources could roll back — so it reads the same whether or not a resource beside it also failed. A failed stack's resolved outputs are then discarded: it publishes none and therefore exports none.
Mutation testing: 11 applied, 11 caught. Two survived on the first pass (a stack record from another account/Region read as the previous deployment; a resource that failed previously read as one this stack owns) and each is now pinned by a test written for it.