Repository navigation
Description
Summary
A CloudFormation stack can carry a service role (RoleARN on CreateStack /
UpdateStack / DeleteStack, surfaced as RoleARN on DescribeStacks). When one
is set, CloudFormation makes every resource call using that role rather than the
calling principal's permissions; when it is absent, it uses the caller's. Substrate
models neither — StackDeployer.dispatch (emulator/cfn_deployer.go:3925) builds a
RequestContext with no Principal at all, and cfnIdentity (:807) carries only
account and region.
Split out of #411, where the immediate decision was which principal a deploy and
its rollback run as. That question is answered there for the no-service-role case (the
stack's creating principal). This issue is the faithful general answer, and it is
strictly larger.
Observables this makes accurate
All of these are reachable through an API call today and all of them are currently
wrong or absent:
RoleARNaccepted onCreateStack/UpdateStack/DeleteStackand reported on
DescribeStacks. Currently not modelled, so a template that sets one round-trips
as though it had not.DeleteStack'sRoleARNoverriding the stack's stored role for that operation
only, which is the documented behaviour and a common source of a stuck delete on
real AWS.- A stack whose service role lacks a permission for one resource: the resource fails,
the stack goesCREATE_FAILED→ROLLBACK_*, and theStackEvent's
ResourceStatusReasonnames the authorization failure. That is a real, seedable
observable and exactly the failure a consumer wants to catch before spending on a
real deploy. InsufficientCapabilitiesExceptionis a distinct existing error and is not this
— worth stating so the two are not conflated during implementation.
Depends on
- Principal-aware test mode: enforce IAM authorization in composition tests #411 — principal-aware enforcement. Without
CheckAccessbeing reached from the
IaC path at all, a service role has nothing to enforce against, so this cannot be
demonstrated. Principal-aware test mode: enforce IAM authorization in composition tests #411 also establishes the per-principal opt-in that keeps existing
tests green.
Notes for whoever takes it
- Verify the request/response shapes and the exact error codes against the
CloudFormation API reference rather than inferring them; in particular what
DescribeStacksreports for a stack with no role, and whether an unassumable role
fails at stack-operation time or at resource-call time. - Keep it inside the scope boundary: substrate models the observation that a call
was denied and the stack status that follows, not any role-assumption machinery
beyond what an API caller can see.
Acceptance criteria
-
RoleARNis accepted, persisted, and reported byDescribeStacks, with shapes
checked against the API reference. - Resource calls a stack makes are attributed to the stack's service role when one
is set, and to the creating principal when it is not (per Principal-aware test mode: enforce IAM authorization in composition tests #411's answer). -
DeleteStack --role-arnoverrides the stored role for that operation only. - A test shows a stack whose role is missing one permission reaching
ROLLBACK_COMPLETEwith aStackEventreason naming the denial. -
docs/services.mdCloudFormation section coversRoleARN.
Activity
scttfrdmn commentedon Aug 5, 2026
Scoped for v0.92.0 alongside #411. Four of the five acceptance criteria are in scope; the fifth is blocked and stays open.
In scope for v0.92.0:
RoleARNaccepted onCreateStack/UpdateStack/DeleteStackand reported byDescribeStacks. Confirmed against the botocore model:RoleARNis a member of all three inputs and of theStackoutput shape.DeleteStack --role-arnoverriding the stored role for that operation only, without persisting it.UpdateStackwithout aRoleARNkeeps the stored one, per the model's "always uses this role for all future operations on the stack".docs/services.mdcoveringRoleARN.Blocked and left open: the
StackEventcriterion.DescribeStackEventsis deliberately refused withUnsupportedOperation(emulator/cloudformation_plugin.go:158-174) because "substrate models stack status, not per-resource stack events" — that is #501, which wants events derived from the event store, with reverse-chronological ordering,NextTokenpagination, and a decision about whether a deploy advances the shared clock. Satisfying one checkbox here would pre-empt that design.The denial is observable in the meantime, without inventing an event model.
DescribeStackResourcesalready derivesCREATE_FAILEDplus aResourceStatusReasonfromDeployedResource.Error(emulator/cloudformation_plugin.go:555-568), andcfnDispatchError(emulator/cfn_deployer.go:3958) lifts the error code out of a 4xx body. So a stack whose role lacks one permission will reachROLLBACK_COMPLETEwithAccessDeniedExceptionnamed in the resource's status reason. v0.92.0 will ship a test asserting exactly that, and theStackEventform of the same observation follows #501.One further finding relevant here: the dependency on #411 is deeper than "principal-aware enforcement".
StackDeployer.dispatch(emulator/cfn_deployer.go:3920) callsregistry.RouteRequestdirectly, andRouteRequestnever callsCheckAccess— the only non-test call site isemulator/server.go:564, in the HTTP path. So authorization has to be added to the deployer, not merely handed a principal. The good news is that create, update, rollback and delete all funnel through that onedispatch, viadeleteStackResources→deleteOneResource→dispatchResourceDeletefor the sweeps, so there is a single place to get it right.This issue will therefore not be closed by v0.92.0; it will move to the next milestone with the
StackEventcriterion outstanding.feat(cloudformation): authorize a stack's resource calls and model it…
docs: document testing IAM permissions and a stack's service role (#411…
scttfrdmn commentedon Aug 5, 2026
v0.92.0 ships four of the five criteria here. Leaving this open for the fifth, and moving it to the next milestone.
Shipped (#574, released in v0.92.0)
RoleARNaccepted and reported — onCreateStack,UpdateStackandDeleteStack, stored on the stack, and reported byDescribeStacks(omitempty, so a stack without one reports nothing rather than an empty string). Length-validated per the model.The documented lifetime semantics, not the convenient ones. An
UpdateStackthat omitsRoleARNkeeps the stored role ("CloudFormation uses the role that was previously associated with the stack"); one that supplies it replaces the role for that update and every operation after. ADeleteStack's applies to that operation only and is not persisted — a delete refused by its override leaves the stack's own role intact, so a retry runs as the identity the stack was created with rather than silently as a different one.Resource calls attributed to the role. Resolution is service role → creating principal → nil, in one place, so create, update, rollback and delete cannot disagree: a resource created by a role is deleted by that role, not by whoever asks for the delete, and a rollback's sweep runs as the identity that created what it is tearing down. Absent a role, calls are attributed to the creating principal — otherwise
CreateStackwould be a way to launder a permission the caller does not have.A denial is observable.
AccessDeniedException, naming the action and the resource ARN, as that resource'sResourceStatusReasoninDescribeStackResources, with the stack reachingROLLBACK_COMPLETE. Verified live:Also documented (#575): the
RoleARNsemantics indocs/services.mdand a "Testing IAM Permissions" section indocs/testing-guide.md.Still open: the
StackEventcriterionBlocked by #501.
DescribeStackEventsis deliberately refused withUnsupportedOperationbecause substrate models stack status, not per-resource stack events, and deriving events from the event store carries its own design questions — ordering, pagination, and a clock decision — that belong to #501 rather than being pre-empted here. Building an event model to satisfy one checkbox would have made this the largest release in the series.Nothing in v0.92.0 changed that analysis, but it does add weight to #501: this is now a second consumer for it, which I've noted there. In the meantime the denial is observable per-resource through
DescribeStackResources, which is what a consumer needs to act on a refused deploy.Moving to the next milestone.
scttfrdmn commentedon Aug 6, 2026
Moved to milestone v0.94.0 — v0.93.0 shipped without it.
Why it moved: unchanged from when it was deferred out of v0.92.0. The acceptance criterion that a role-attributed call surfaces in
DescribeStackEventscannot be written against aDescribeStackEventsthat has no backing event model, which is #501. Nothing in v0.93.0 touched CloudFormation.Did the shipped release change the analysis? No, but it is worth recording one thing that is now precedent rather than speculation. v0.93.0's #540 work established that a control-plane seed — not a fault rule — is the right shape when a test needs an outcome the emulator cannot derive from state, because a seed reaches the plugin and can therefore write the consequence of the outcome, whereas a fault short-circuits at Step 4.5 and writes no state. If this issue ends up needing a way to make a role-attributed call fail as the role (rather than as the caller), that is the pattern to follow, and
emulator/s3_conditional_control.gois now the closest in-repo example.Still blocked on #501.
scttfrdmn commentedon Aug 6, 2026
Moved to milestone v0.95.0. Still blocked on #501 (no IAM authorization decision to
attribute a call to), so it was deferred out of v0.94.0 rather than attempted.
Nothing in v0.94.0 changes the analysis here. The release touched the deployer's
physical-name resolution (#560) and its delete sweep (#581), both of which run inside
one dispatch per resource — the layer this issue needs is around that dispatch, deciding
which principal it is made as. The one point of contact is that resource calls are now
dispatched from more places in the delete path than before: an instance profile's delete
emits a
RemoveRoleFromInstanceProfilepre-step throughdispatchResourceDeletealongside its own delete. Whatever attributes a call to the stack's service role will
need to cover the pre-step too, or a stack with a service role would attribute part of
its own teardown to the caller.
scttfrdmn commentedon Aug 9, 2026
The fifth criterion is met
The remaining acceptance criterion was "a test shows a stack whose role is missing one
permission reaching
ROLLBACK_COMPLETEwith aStackEventreason naming the denial".It could not be written because
DescribeStackEventsreturnedUnsupportedOperation(400), which is why this issue deferred across v0.92.0 → v0.93.0 → v0.94.0 → v0.95.0.
#501 shipped the events model, so the criterion is now asserted in three places:
emulator/cfn_service_role_test.go—TestCFN_DeniedResourceNamesTheDenialInStackEvents:a stack under a role granting only
s3:ListBucketreachesROLLBACK_COMPLETE, itsnewest event is the stack's
ROLLBACK_COMPLETE, and aCREATE_FAILEDevent for therefused resource names both
AccessDeniedExceptionands3:CreateBucket.test/e2e/journey_cfn_events_test.go—TestJourney_StackEventsNameARoleDenial: thesame chain through the real AWS SDK, with the role built via the IAM SDK rather than
seeded into state, so the whole sequence a consumer writes is exercised.
The
DescribeStackResourcesassertion this issue already had is kept: both views nowshare one derivation (
cfnResourceStatus), so they cannot disagree about whether aresource failed.
docs/services.mdno longer says the denial is "not reported as aStackEvent".All five criteria are met, so this closes with #501.
feat(cfn): DescribeStackEvents answers, derived from the stack record (…