Skip to content

fix(ttl-reaper): pass sam deploy parameters via a params file - #455

Merged
scttfrdmn merged 4 commits into
mainfrom
fix/reaper-deploy-empty-params
Jul 31, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
fix/reaper-deploy-empty-params

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Found while performing the deploy #453 made possible: make deploy did not actually work with the parameters #453 added.

The bug

sam matches the entire --parameter-overrides string against a single regex (types.py:194-208), and an empty value breaks that match. NOTIFY_URL, DNS_ZONE_ID and DNS_DOMAIN are all empty by default, so it failed two different ways:

Loudly, with the short Key=Value form:

Error: Invalid value for '--parameter-overrides': NotifyUrl= is not a valid format.

Silently, with the long ParameterKey=…,ParameterValue=… form — it falls through to the other pattern and mis-keys everything:

Parameter overrides : {"Environment": "production", "DryRun": "true",
  "ParameterKey": "NotifyUrl,ParameterValue=", "ScanSelf": "false", ...}

The silent form is the one that matters: the deploy succeeds, but NotifyUrl was never overridden and a bogus parameter named ParameterKey was submitted in its place. A deploy that applies something other than what was asked for, with nothing to notice. Repeating the flag per pair isn't a fix either — the last occurrence wins and the rest are dropped ({"DnsSweep": "true"} only).

The fix

Generate a file:// params file — the only form that handles empty values. Verified all eight parameters arrive intact with NotifyUrl as "":

Parameter overrides : {"Environment": "production", "DryRun": "true", "NotifyUrl": "",
  "ScanSelf": "false", "RoleArns": "arn:aws:iam::435415984226:role/spawn-ttl-reaper-ec2",
  "DnsZoneId": "Z0341053304H0DQXF6U4X", "DnsDomain": "spore.host", "DnsSweep": "true"}

The deploy also echoes the mode-setting parameters (dry-run, scan-self, dns-sweep, zone, domain) so a deploy can't quietly leave a feature off — but not NotifyUrl, which is a Slack webhook secret and doesn't belong in a console or CI log. The generated file is gitignored and removed by make clean.

Verification

Deployed the reaper for real (approved, dry-run mode). Parameters landed correctly and the live init line now reads:

ttl-reaper initialized (accounts=[435415984226], …, dry-run=true, …, dns-sweep=true)

Before this it had no dns-sweep field at all. An on-demand invoke returns the post-#438 summary shape ("dns_scanned":0,"dns_reaped":0) with zero errors. DNSScanned=0 is expected — the sweep only covers accounts in RoleArns (dev 5k0zfnmq, which has no records); the known orphan is under 4zlw3a1t, an account not in that list, as #453's README now warns.

Found while performing the deploy #453 made possible: `make deploy` did
not work at all with the parameters #453 added. sam matches the ENTIRE
--parameter-overrides string against one regex, and an empty value
breaks that match. NOTIFY_URL, DNS_ZONE_ID and DNS_DOMAIN are all empty
by default, so the invocation either failed at argument parsing —

  Error: Invalid value for '--parameter-overrides': NotifyUrl= is not a
  valid format.

— or, with the long ParameterKey=…,ParameterValue=… form, fell through
to a different pattern and mis-keyed everything:

  Parameter overrides : {"Environment": "production", "DryRun": "true",
    "ParameterKey": "NotifyUrl,ParameterValue=", ...}

That second form is the dangerous one. The deploy SUCCEEDS, but NotifyUrl
was never overridden and a bogus "ParameterKey" parameter was submitted
instead — a deploy that applies something other than what was asked for,
with no error to notice. Repeating the flag per pair doesn't work either:
the last occurrence wins and the rest are silently dropped.

Generate a file:// params file instead, the only form that accepts empty
values (verified: all eight parameters arrive intact, NotifyUrl as ""),
and echo the mode-setting parameters — dry-run, scan-self, dns-sweep,
zone, domain — so a deploy can never quietly leave a feature off. Not
NotifyUrl: it's a Slack webhook secret and does not belong in a console
or CI log. The generated file is gitignored and removed by `make clean`.

Verified by deploying the reaper for real: parameters landed correctly,
and the live init line now reads dns-sweep=true (sweep enabled, still
dry-run) where before it had no dns-sweep field at all.
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.95189% with 134 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/taskpool/queue.go 47.95% 43 Missing and 8 partials ⚠️
pkg/taskcohort/adapter.go 60.52% 43 Missing and 2 partials ⚠️
pkg/taskpool/worker.go 51.89% 31 Missing and 7 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit f5bddab into main Jul 31, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/reaper-deploy-empty-params branch July 31, 2026 01:38
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