Repository navigation
Description
Against ghcr.io/scttfrdmn/substrate:0.88.0, CloudFormation resolves a stack by
name only. Passing the stack's own ARN — the value create_stack and
describe_stacks both hand back — fails, and the delete_stack case fails
silently with HTTP 200.
Real CloudFormation accepts either form for StackName. The
API reference
is explicit: "The name or the unique stack ID that's associated with the stack."
Reproducer
import boto3
cfn = boto3.client(
"cloudformation",
endpoint_url="http://localhost:4566",
region_name="us-east-1",
aws_access_key_id="test",
aws_secret_access_key="test",
)
TEMPLATE = """
Resources:
Bucket:
Type: AWS::S3::Bucket
"""
arn = cfn.create_stack(StackName="arn-probe", TemplateBody=TEMPLATE)["StackId"]
print("StackId:", arn)
cfn.get_waiter("stack_create_complete").wait(StackName="arn-probe")
# 1. describe by ARN -> ValidationError, though this is the ARN substrate returned
try:
cfn.describe_stacks(StackName=arn)
print("describe by ARN: ok")
except Exception as e:
print("describe by ARN:", type(e).__name__, e)
# 2. delete by ARN -> HTTP 200, and the stack is still there
resp = cfn.delete_stack(StackName=arn)
print("delete by ARN HTTP:", resp["ResponseMetadata"]["HTTPStatusCode"])
print("still present:", [
s["StackName"] for s in cfn.describe_stacks()["Stacks"]
if s["StackName"] == "arn-probe"
])
# 3. delete by name -> gone
cfn.delete_stack(StackName="arn-probe")
print("after delete by name:", [
s["StackName"] for s in cfn.describe_stacks()["Stacks"]
if s["StackName"] == "arn-probe"
])Observed:
StackId: arn:aws:cloudformation:us-east-1:123456789012:stack/arn-probe/...
describe by ARN: ClientError An error occurred (ValidationError) ... does not exist
delete by ARN HTTP: 200
still present: ['arn-probe']
after delete by name: []
Why the silent case matters
The delete_stack half is the damaging one, because nothing signals failure. A
caller that stores the StackId it was given — which is the natural thing to store,
since it is what identifies the stack unambiguously — and later deletes by it sees
HTTP 200 and reasonably concludes the stack is gone.
That is exactly what happened downstream in
parsl-ephemeral-provider:
its detached mode keeps the bastion's StackId and calls
delete_stack(StackName=self.bastion_id) in teardown. Against substrate the teardown
became a silent no-op, and the failure surfaced one test later as AlreadyExists on
the next stack create — a confusing place to debug from, several steps removed from
the call that actually did nothing.
Found while moving that project's integration suite off moto and onto substrate
(parsl-ephemeral-provider#183).
Suggested fix
Resolve StackName through the same lookup for both forms: if the value parses as a
stack ARN, extract the stack name (and ideally match the stack ID, so a stale ARN for
a deleted-and-recreated stack is rejected rather than silently retargeted). At
minimum, an unresolvable StackName should raise ValidationError from
delete_stack rather than return 200 — a delete that does nothing should not report
success.
Activity
scttfrdmn commentedon Aug 3, 2026
Reproduced exactly as reported, against
v0.89.0. Thedelete_stackhalf is the seriousone, and it is now sharper than when this was filed: v0.89.0 shipped the resource sweep
(#518), so a by-name delete really does tear down the stack's resources — while a
by-ARN delete still answers
200and does nothing at all. The gap between the twowidened.
This is precisely the defect shape v0.89.0 was built around — substrate reports a
successful deletion of something it did not delete — reached by a different route. An ARN
substrate itself minted and handed to the caller is not accepted back as an identifier.
Cause, measured. Every read goes through
d.state.Get(ctx, cfnNamespace, "stack:"+stackName)with the caller's string used verbatim as the key: 8 call sites in
emulator/cfn_deployer.go(
:1096, 1163, 1203, 1222, 1451, 1502, 1632, 1717) and 1 inemulator/cfn_rollback.go. TheARN is built by
cfnStackARN(cfn_deployer.go:4530) from acfnDeterministicUUID, so thename is recoverable from the ARN — nothing needs to be stored to fix this. The fix is one
shared resolver that normalises an ARN to its stack name before the lookup, not nine edits.
DeleteStack(:1119) then compounds it: an unresolvable name is deliberately treated assuccess — deleting an absent stack is a success — which is right for a genuinely absent
stack and wrong for an identifier it simply failed to parse. That is the whole reason the
ARN case answers
200while deleting nothing. The resolver has to run before thattolerance applies.
One correction to the report: the ARN in a
ValidationErrormessage should name the stackas given, but real CloudFormation's
DescribeStacksaccepts either form, so both the errorpath and the success path change here.
Milestoned for v0.90.0 with
priority: high.test(cfn): every call site propagates an out-of-scope ARN refusal (#544)
fix(cfn): accept a stack ARN wherever StackName is taken (#544) (#554)