Repository navigation
Description
Every customer account's trust policy names the reaper's execution role by an ARN containing a CloudFormation-generated physical ID:
arn:aws:iam::966362334030:role/spawn-ttl-reaper-production-TTLReaperFunctionRole-ZJ84YZ2dCPei
^^^^^^^^^^^^
Recreating the spawn-ttl-reaper-production stack regenerates that suffix. Every trust policy referencing the old ARN then denies, simultaneously, across every account.
Why it is worse than it sounds
This is #457 trap 1, and #469 documented the consequence precisely: from the reaper's side, "our role ARN changed" is indistinguishable from "the entire customer base uninstalled at once." #469's per-account aggregation means each broken account contributes 1 to AccountsDenied, and REAPER REACHED NO ACCOUNTS fires — which is the correct signal, but the operator sees a mass-uninstall shape and has to already know about this trap to look at the role ARN first. (The README's alarm table says "investigate our side first — the #457 role-ARN suffix" for exactly this reason.)
Recovery is O(number of accounts) and needs admin in each: every account must redeploy ttl-reaper-cross-account-role.yaml with the new ARN. For third-party accounts that means asking each owner. There is no way to fix it from the infra account alone.
Now affecting 2 accounts, not 1
435415984226(Mycelium Development)942542972736— added 2026-07-31
Each account added multiplies the blast radius. Fixing this gets strictly more expensive over time and is cheapest now.
Proposed fix
Give the function role a stable, explicit name so its ARN is deterministic and stack-recreation-safe:
TTLReaperFunctionRole:
Properties:
RoleName: !Sub 'spawn-ttl-reaper-${Environment}-role'Requires CAPABILITY_NAMED_IAM (the Makefile currently passes only CAPABILITY_IAM) and blocks a no-downtime rename, since the role cannot be renamed in place. Migration is the careful part and must not lock us out mid-flight:
- Add the new stable-named role alongside the existing one.
- Have each account's trust policy accept both principals.
- Cut the function over to the new role; confirm
AccountsDenied: 0. - Drop the old principal from each account, then the old role.
A Path-based ARN or a dedicated non-SAM role stack are alternatives; the two-principal migration is the part that matters regardless of which is chosen.
Acceptance
- The reaper's role ARN survives a full stack delete/recreate.
deployment/cloudformation/ttl-reaper-cross-account-role.yamldocuments that the ARN is now stable.- Migration does not require simultaneous redeploys across accounts.
Related: #457 (trap 1), #469 (why the failure presents as mass-uninstall).
Activity
feat(autoscale): report whether anything will act on a group (#773)
scttfrdmn commentedon Oct 10, 2026
Blast radius is smaller than this issue assumes — which is the argument for fixing it now
"breaks EVERY onboarded account at once" is currently one account. Measured:
The reaper's own log agrees —
Accounts:1.So the fix costs one coordinated trust-policy update today, and one per onboarded
account later. The cheapest moment to do this is before the second account
onboards, which reframes it from "a latent trap" to "a closing window".
The fix: give the role a stable name
With an explicit
RoleName, deleting and recreating the stack produces the samename and therefore the same ARN, so the cross-account trust survives. That is
the actual root cause — not the suffix itself, but that the suffix is regenerated.
The sequencing constraint, verified rather than assumed
The obvious plan is "add the new ARN to the trust, then switch". IAM will not
let you, because it validates principals on write:
(Probed in the dev account; it created nothing, confirmed with
get-role→NoSuchEntity.)So the new role must exist before it can be trusted, which forces an overlap
migration rather than a swap.
Plan — five steps, no window where reaping is dead
AWS::IAM::RolewithRoleName: spawn-ttl-reaper-production-role, carrying the same policies SAMcurrently generates from
Policies:. Do not point the function at it yet.Deploy → the role exists, nothing uses it.
spawn-ttl-reaper-ec2's trust alongsidethe existing one. Both are now trusted.
Role: !GetAtt …), drop thePolicies:block. Deploy.simulate-principal-policyforec2:TerminateInstanceswithec2:ResourceTag/spawn:managed=truefrom the newrole, plus one real dry-run reaper invocation showing
Accounts:1and anon-zero
Scanned. A dry-run that scans 0 proves nothing — that was the--fsx-lifecycle ephemeral did not reap the filesystem when the instance terminated (1.2 TiB left AVAILABLE and billing) #613 lesson.
template. Deploy. Re-verify.
Each step is independently revertible, and reaping keeps working throughout
because step 2 precedes step 3.
Why not the obvious alternative
Trusting
arn:aws:iam::966362334030:rootwith theExternalIdcondition woulddodge the chicken-and-egg entirely (root always exists) and survive any role
recreation. It is also the AWS-documented cross-account pattern.
Rejected because it widens the trust from "this reaper's role" to "any
principal in the infra account presenting the ExternalId", and what that trust
grants is
ec2:TerminateInstances. A narrower trust that survives recreation isachievable — that is what step 1 buys — so the widening is not necessary.
Note on the deploy mechanism
Steps 1, 3 and 5 are
ttl-reaperdeploys, which means the Makefile'sread-live-parameters-first path and a reviewed change set each time. The role
change will show as a replacement, which is expected; what must not appear
is any change to the DynamoDB table or the function's
Codebeyond theintentional rebuild.
scttfrdmn commentedon Oct 10, 2026
Revising my own plan: step 1 is riskier than it needs to be, and there is a better fix
I proposed giving the role a stable
RoleName. Starting it, two things turned up.Why renaming is riskier than it looked
SAM generates the role from a
Policies:block with 5 entries and heavyconditional logic — 16
!If … AWS::NoValueoccurrences in the template, andthe live role proves they fire: its inline policies are
Policy1is absent — one entry is conditioned out at the current parametervalues. So an explicit
AWS::IAM::Rolewould have to reproduce five conditionalpolicy entries by hand, on the production reaper's IAM, where a mistake either
over-grants
ec2:TerminateInstancesor silently disarms reaping. That is a poorplace to hand-transcribe conditionals.
The better fix: make the trust pattern-matched, and change nothing in the reaper
The root cause is not the suffix — it is that the suffix is regenerated. That
can be absorbed on the dev side only, with no change to the reaper's template
or IAM at all:
{ "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::966362334030:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "spawn-ttl-reaper" }, "ArnLike": { "aws:PrincipalArn": "arn:aws:iam::966362334030:role/spawn-ttl-reaper-production-TTLReaperFunctionRole-*" } } }:rootalways exists, so the chicken-and-egg that forced a five-stepoverlap disappears entirely.
ArnLikeonaws:PrincipalArnkeeps it narrow — only a role matching thereaper's generated-name pattern, not "anything in the infra account", which is
why I rejected bare
:rootearlier.Verified, not assumed
MalformedPolicyDocument; this one created cleanly(
arn:aws:iam::435415984226:role/spawn-trust-probe-476b).…/OrganizationAccountAccessRole/dev-admin-session— same account, wrong ARNpattern — returned
AccessDenied. So the condition is doing work rather thandecorating.
NoSuchEntity.What is not yet verified is the positive case: that the reaper's actual role
still assumes successfully. That cannot be simulated from here — trust evaluation
is not
simulate-principal-policy-shaped — so it is the gate for the changeitself, below.
Revised plan — two steps, no overlap migration
one policy document, instantly revertible (keep the old document to hand).
Accounts:1with a non-zeroScanned. A dry-run that scans 0 provesnothing — the --fsx-lifecycle ephemeral did not reap the filesystem when the instance terminated (1.2 TiB left AVAILABLE and billing) #613 lesson — so this needs at least one instance in the dev
account, or it is inconclusive and should be treated as such.
If step 2 fails, revert step 1 and we are back to today's state with nothing lost.
Trade-off, stated
The trust is now "a role in 966362334030 whose name matches
spawn-ttl-reaper-production-TTLReaperFunctionRole-*, presenting the ExternalId"rather than one exact ARN. Marginally wider: another role could be named into
that pattern by someone who can already create roles in the infra account — which
is a principal who could equally modify the reaper. I judge that acceptable
against hand-transcribing five conditional IAM policies on the live reaper, but
it is a judgement and worth disagreeing with.
The stable-
RoleNameroute stays available and is strictly narrower; it is justnot worth its risk today, with one onboarded account and the regeneration
hazard removable from the other side.
docs: map the deployed control plane in the infra account (#782)
fix(reaper): trust the reaper by name pattern, not a generated role ARN
fix(reaper): trust the reaper by name pattern, not a generated role A…
Fix the docs that told users to do impossible things (#850)