Skip to content

fix(reaper): grant cross-account role fsx:DescribeFileSystems + DeleteFileSystem (#210) - #212

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/210-reaper-fsx-iam
Jun 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/210-reaper-fsx-iam

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #210, #192.

The gap (found while deploying the #210 reaper safety net)

When I redeployed the ttl-reaper in enforce mode and ran it, every region returned AccessDeniedException on fsx:DescribeFileSystems (Errors:11). The cross-account role template (ttl-reaper-cross-account-role.yaml) grants EC2 permissions only — no FSx at all. So the reaper's entire FSx path — both the original #192 refcount reaping and the new #210 ephemeral-orphan net — has never actually worked in deployment. It went unnoticed because the reaper ran in dry-run, where the per-region FSx error was just logged.

Fix

Add to the role policy:

  • fsx:DescribeFileSystems — Resource: '*' (no resource-level ARN exists for it), mirroring the existing ec2:DescribeInstances.
  • fsx:DeleteFileSystem — scoped to aws:ResourceTag/spawn:managed: 'true', mirroring the ec2:TerminateInstances guard so a user's own (unmanaged) filesystem can never be deleted by the reaper.

Verified live

After updating the dev-account role stack (435415984226) with this template, re-invoking the reaper went from Errors:11 (one AccessDenied per region) to:

ttl-reaper done: {Accounts:1 Scanned:0 ... Errors:0 FSxScanned:0 FSxExpired:0 FSxReaped:0 FSxSkipped:0}

FSx scan now succeeds across all 11 regions (0 filesystems present, so nothing reaped — correctly). The reaper Lambda is deployed in enforce mode (REAPER_DRY_RUN=false).

Deployment note: the dev-account role stack has already been updated with this template (live), and the reaper redeployed + enforce-flipped. This PR brings the source-of-truth template in line with what's deployed. Any other spore-launching account's role stack must be re-deployed from this template to get the FSx permissions.

…eFileSystem (#210)

The ttl-reaper cross-account role had EC2 permissions only — no FSx. So the
reaper's entire FSx path (#192 refcount reaping AND the #210 ephemeral-orphan
net) silently AccessDenied-errored in every region and never reaped any
filesystem. This went unnoticed because the reaper ran in dry-run.

Add fsx:DescribeFileSystems (Resource * — no resource-level ARN) and
fsx:DeleteFileSystem (scoped to aws:ResourceTag/spawn:managed=true, mirroring
the TerminateInstances guard so a user's own FSx is untouchable). Verified live:
after updating the dev-account role stack, the reaper run goes from Errors:11
(one AccessDenied per region) to Errors:0 with the FSx scan working.

Refs #210, #192.
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 437c4b4 into main Jun 17, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/210-reaper-fsx-iam branch June 17, 2026 16:23
scttfrdmn added a commit that referenced this pull request Jun 25, 2026
… (#249)

#247 — the reaper now tears down a reaped instance's Route53 records itself.
spored's graceful shutdown deletes its DNS record, but the reaper only fires when
spored FAILED (dead/wedged/never-ran), so reaped instances leaked their A-records
(and the #121 friendly-name alias CNAME) into the zone forever — the root cause of
the orphaned records observed in spore.host. Per the backstop principle, the
reaper does NOT wake the dead daemon to clean up; it performs the teardown
out-of-band:
- captures spawn:dns-name / spawn:account-base36 / spawn:account-name in evaluate()
- deletes {dns-name}.{account-base36}.{domain} (canonical A) and, when present,
  {dns-name}.{account-name}.{domain} (the #121 alias CNAME)
- uses the reaper's OWN (infra-account) Route53 creds — the zone lives there, not
  in the per-instance cross-account role
- best-effort + REAPER_DRY_RUN-aware; runs AFTER terminate so it can never block
  the hard-deadline guarantee (#72)
- enabled via REAPER_DNS_ZONE_ID + REAPER_DNS_DOMAIN (both empty = off, no
  route53 IAM attached); template.yaml gains scoped
  route53:ChangeResourceRecordSets/ListResourceRecordSets + a DnsTeardownEnabled
  condition. Mirrors the reaper's existing FSx-cleanup ownership (#192/#212).

#248 — scripts/deploy-custom-dns.sh built the Lambda with `go build main.go`,
which misses signature.go (undefined: verifyInstanceIdentitySignature). Fixed to
`go build .`.

Tests: dnsRecordsToDelete (pure: A-only / A+alias / no-dns / missing-base36 /
empty-domain) + evaluate() populates the DNS fields. cfn-lint clean.
Fixes #247, #248.
scttfrdmn added a commit that referenced this pull request Jul 31, 2026
The reaper exists because #65 showed a dead spored monitor loop lets
instances run forever. That guarantee was only as good as our ability to
notice when the REAPER was the thing that had died — and it was not
noticeable at all:

  - handler always returned nil, so the Lambda Errors metric never moved
    however many scans failed
  - Summary went to one log line nothing read
  - the Slack webhook fires only on SUCCESSFUL reaps
  - no metric filter and no alarm existed on this function in either repo

A run whose every scan was refused looked exactly like a run with nothing
expired.

#469 was filed as "a dead account's assume-role failures poison sum.Errors
forever" (11 regions × 6 runs/hour = 66/hour). Exploring it showed the
framing was wrong: sum.Errors drives nothing, so quietening it would have
made the reaper calmer without making it safer. The noise was a symptom of
there being nothing listening.

Errors is the only field in Summary that says a scan did NOT happen; every
other field counts something that did. Failures are now classified
(AccessDenied/AccessDeniedException/UnauthorizedOperation vs everything
else, reusing portal-account-prober's isDenied code set) and aggregated per
ACCOUNT — credentials are per account, so eleven identical denials are one
observation. Errors keeps its "investigate this" meaning for operational
failures only; AccountsDenied and FSxAccountsDenied carry the standing
configuration facts.

FSx is tracked separately because fsx:* is a different grant from ec2:*: an
account can scan instances perfectly and never reclaim a filesystem, which
is #212 exactly. Sharing one signal would let the EC2 success mask it again.

Three sentinel log lines exist so they can be alarmed on, with four alarms
in the reaper's own template.yaml (ALARMS_ENABLED, default on; optional
ALARM_TOPIC_ARN): zero accounts reached, an account refused everywhere, FSx
refused everywhere, and the Lambda erroring outright — that last because a
run that dies never reaches the code emitting the others, so without it the
loudest failure would be the quietest signal. The zero-accounts text points
at OUR side first: the reaper's role ARN embeds a CFN-generated physical ID,
so recreating the stack breaks every customer's trust policy at once (#457),
indistinguishable from the whole customer base uninstalling simultaneously.

A denied account is still attempted every run — quiescing means not counting
it as a surprise, never ceasing to look. The registry annotates a denial as
corroboration only: it describes spore-portal-onboard, not the
spawn-ttl-reaper-ec2 role that refused us, so it can never gate anything.
It is read at most once per run and not at all when nothing was denied.

ec2For/fsxFor became interfaces and handler delegates to (*reaper).run so
the failure paths can be driven in tests. Mutation testing is why: with
concrete clients, deleting the reportOutcomes call, the per-region
outcome.record, the FSx denial re-route, or handler's delegation entirely
left every test passing. A failure-observability change that cannot itself
be observed failing is the one unacceptable outcome. 17 mutants killed, one
confirmed equivalent (single-page FSx fakes cannot distinguish the
first-page guard).

Nothing here deletes or terminates; it only classifies and reports.

Closes #469. Addresses #457 failure mode A and #254 idea 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant