Repository navigation
fix(reaper): grant cross-account role fsx:DescribeFileSystems + DeleteFileSystem (#210) - #212
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Jun 25, 2026
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.
This was referenced Jun 25, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AccessDeniedExceptiononfsx: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 existingec2:DescribeInstances.fsx:DeleteFileSystem— scoped toaws:ResourceTag/spawn:managed: 'true', mirroring theec2:TerminateInstancesguard 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: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).