Repository navigation
Add a deploy script for cost-history-collector - #853
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
It was the one live Lambda nothing in this repo could ship: invoked hourly by an enabled EventBridge rule, last modified 2026-02-20, and the only references to it anywhere were its own go.mod, a .gitignore entry, a Dependabot entry and the changelog. No deploy script, no Makefile target, no CFN or SAM template. It is not dead code — lambda/dashboard-api/cost_history.go serves GET /api/cost-history from the spawn-cost-history table it fills, which holds thousands of hourly snapshots, and the function ran successfully minutes before this was written. It was simply unreachable from the repo, so Dependabot had spent eight months bumping a module that could not get to production. Modelled on deploy-scheduler-handler.sh so the existing gates apply automatically rather than needing new ones. Verified by reverting each: removing the account assertion fails TestDeployScriptsAssertTheAccount NAMING the new script, and removing put-retention-policy fails the census. A gate that passes because it never looked at the file is worth nothing, so both were checked rather than assumed. Carries the hardening those scripts earned the hard way: the runtime is asserted on every deploy and not only on create (#716 — a script declared provided.al2023 and redeployed for ten months while the function stayed on provided.al2, because update-function-code does not change the runtime); spawn:version is stamped from `git describe --dirty` so deployed bytes trace to a commit, which is the only thing that would have revealed this function being eight months behind its source; the PACKAGE is built rather than main.go; and AWS_REGION is ignored in favour of an explicit region, since honouring it is how a second scheduler-handler came to exist in us-west-2. It deliberately does NOT create the hourly EventBridge rule. The live one already exists, and a deploy script that also owned the schedule could silently change how often a cost collector runs. Closes #848
scttfrdmn
force-pushed
the
feat/848-cost-history-deploy
branch
from
October 11, 2026 23:07
996e832 to
7d2eeca
Compare
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.
Closes #848.
Correctness audit 2026-10.What this was
The one live Lambda nothing in this repo could ship:
No deploy script, no Makefile target, no CFN or SAM template.
It is not dead code.
lambda/dashboard-api/cost_history.goservesGET /api/cost-historyfrom thespawn-cost-historytable it fills — 2,161 items — andthe collector ran successfully for 3 users minutes before this was written. It was simply
unreachable from the repo, so Dependabot had spent eight months bumping a module that could
not get to production.
Verified that the existing gates actually see it
Modelled on
deploy-scheduler-handler.shprecisely so the gates apply without needing newones — and then checked, because a gate that passes by not looking at the file is worth
nothing:
Hardening those scripts earned the hard way
update-function-codedoes not change the runtime, so a script can declareprovided.al2023and redeploy forever while the function stays onprovided.al2— whichis exactly what happened to scheduler-handler, deployed 2026-01 and still al2 in October
(Nothing tracks deployed Lambda runtime versions: two are already stale (provided.al2, python3.11) and a runtime reaching EOL would be silent #716).
spawn:versionis stamped fromgit describe --dirty, so deployed bytes trace to acommit and an uncommitted deploy says so. This is the only thing that would have revealed
this function being eight months behind its source.
main.go— naming files ships a binary missing any sourcefile added later.
AWS_REGIONis ignored in favour of an explicit region, since honouring an ambientregion is how a second scheduler-handler came to exist in us-west-2 while the stale one
stayed in us-east-1.
Architecture, timeout, memory, role and runtime were read from the live function rather
than guessed:
x86_64, 300s, 512 MB,SpawnDashboardLambdaRole,provided.al2023.One deliberate omission
It does not create the hourly EventBridge rule. The live one
(
spawn-cost-history-collector-hourly) already exists, and a deploy script that also ownedthe schedule would be able to silently change how often a cost collector runs. The create
path says so explicitly, since a freshly created function would otherwise never be invoked.
Verification
make check(all nested modules),make check-docs, changelog gate,semgrep0 findings,shellcheckclean,bash -nclean,scripts/lambda-deploy-census.shpassing.Not run. This adds the script; deploying is a separate, live action.