Skip to content

fix(reaper): region-explicit deploy; an unreadable stack must abort, not reset - #666

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/650-followup-region-and-empty-live
Oct 4, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/650-followup-region-and-empty-live

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Follow-up to #650. The fix for #650 disarmed the live production reaper. I caught it by checking the stack after deploying rather than trusting the deploy's own output — and the deploy's own output is the reason it got that far.

What happened

The Makefile's describe-stacks call had no --region. So it resolved against the profile's default region, the stack read as "not found", the || echo '[]' branch wrote an empty live set, and every parameter fell back to its template default — DryRun among them, whose default is true.

Result: DryRun=true, DNS sweep off, DNS domain blanked, alarm topic detached. The reaper kept running and reporting and stopped terminating anything. Precisely the failure #650 exists to prevent, reintroduced by the fix for it.

What let it past me

Not the logic — the reporting. The merge printed:

deploy changes no parameters (code only); 16 inherited from the live stack.

...while setting all 16 from defaults. Its change notes only fired when a live value existed to differ from; with no live values there were no notes, so asserting 16 defaults looked identical to inheriting 16. I read that line and believed it.

That's the more important bug of the two.

Three changes

  1. Every aws cloudformation call in the deploy path is region-explicit (REGION?=us-east-1), including sam deploy.
  2. A describe-stacks failure that is not a genuinely absent stack now aborts. Collapsing every failure into '[]' is what silently reset the stack. A first deploy (does not exist) is still fine and says so.
  3. An empty live set is now the loudest case — it warns that all 16 values come from template defaults and will RESET an existing stack, and lists each as a change.

Tests

All three, including TestDeployReadsTheStackInTheRightRegion, which reads the Makefile — the region bug isn't visible in the merge logic at all, it's in the call that feeds it. Both confirmed to fail when inverted.

Production state

Restored from a snapshot taken before the bad deploy: all 16 parameters match the original, zero drift, DryRun=false (armed), DnsSweep=true, and all five alarms re-wired. Verified after restoring, not assumed.

Worth saying

This is the second time today a reaper IAM/deploy change looked correct and wasn't — the other being #652's ec2:ResourceTag on an ssm: action (#665). Both share a shape: YAML that no compiler and no test could reach, verified only by asking AWS afterwards. It's a concrete argument for the standing preference to drop CloudFormation and express this in Go against the API, where pkg/reaperiam already has a real drift test and pkg/reaperdeploy already makes direct calls.

…not reset

Follow-up to #650. The fix for #650 disarmed the live production reaper.

The Makefile's describe-stacks had no --region, so it resolved against the
profile's default region, the stack read as 'not found', the `|| echo '[]'`
branch wrote an EMPTY live set, and every parameter fell back to its template
default — DryRun among them, whose default is 'true'. The reaper went to
dry-run: still running, still reporting, terminating nothing. Precisely the
failure #650 exists to prevent, reintroduced by the fix for it.

What let it past me was the reporting, not the logic. The merge printed 'deploy
changes no parameters (code only)' because its change notes only fired when a
live value existed to differ from. With no live values there were no notes, so
asserting all 16 defaults looked identical to inheriting all 16. I read that
message and believed it.

Three changes:

  - Every aws cloudformation call in the deploy path is region-explicit
    (REGION?=us-east-1), including sam deploy.
  - A describe-stacks failure that is NOT a genuinely absent stack now ABORTS.
    Collapsing every failure into '[]' is what silently reset the stack; a first
    deploy (stack 'does not exist') is still fine and says so.
  - An empty live set is now the LOUDEST case: it warns that all 16 values come
    from template defaults and will RESET an existing stack, and lists each one
    as a change.

Tests for all three. TestDeployReadsTheStackInTheRightRegion reads the Makefile,
because the region bug is not visible in the merge logic at all — it is in the
call that feeds it. Both confirmed to fail when inverted.

Production was restored from a snapshot taken before the bad deploy: all 16
parameters match the original with zero drift, DryRun=false, DnsSweep=true, and
all five alarms re-wired.
@codecov

codecov Bot commented Oct 4, 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 6fd2ef8 into main Oct 4, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/650-followup-region-and-empty-live branch October 4, 2026 04:19
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