Repository navigation
Description
Found while fixing #637. Untracking that 22 MiB binary stopped it being committed; it is still built into the same directory — and that directory is what SAM uploads.
Measured, in production
$ aws lambda get-function-configuration --function-name <fn> --query CodeSize
spawn-ttl-reaper-production 79387256 # 75.7 MiB
spawn-autoscale-orchestrator-production 7457417 # 7.1 MiBThe reaper's real artifact is a single bootstrap binary — roughly the 7 MiB the autoscale function shows. It is deployed at 75.7 MiB, a >10x inflation, on the one component whose job is guarding against runaway cost.
Mechanism (read from the installed SAM CLI, not assumed)
lambda/ttl-reaper/template.yaml and lambda/autoscale-orchestrator/template.yaml both set CodeUri: ., and their Makefiles run sam deploy --template-file template.yaml --resolve-s3 from inside that directory. SAM CLI 1.166.2, samcli/lib/package/utils.py:283:
for root, _, files in os.walk(source_root, followlinks=True):
for filename in files:No filtering of any kind — every file, dotfiles included.
.samignoreis not a SAM CLI feature.grep -ril samignoreacross all ofsamcli/returns nothing. I suggested adding one on A 22 MiB compiled binary is tracked in git at lambda/autoscale-orchestrator/autoscale-orchestrator #637; that was wrong, and this issue replaces that suggestion.- No
.gitignorerespect either (grep -rn gitignore samcli/lib/package/→ none). So A 22 MiB compiled binary is tracked in git at lambda/autoscale-orchestrator/autoscale-orchestrator #637's.gitignorework does nothing for deployment: the binary is out of git but still lands in the zip. lambda/pipeline-orchestrator/template.yamldeclares noCodeUriat all, which is not a reprieve.ServerlessFunctionResourceinheritsPACKAGE_NULL_PROPERTY = True, andupload_local_artifacts' own docstring reads: "If path is omitted, this method will zip the current working folder and upload." It packages whatevercwdis — worse, because it's implicit.
What rides along
Local directory sizes — what a make deploy right now would upload:
| lambda | dir size | contents of note |
|---|---|---|
ttl-reaper |
96 MB | ttl-reaper dev binary (74 MB), function.zip (26 MB) |
pipeline-orchestrator |
39 MB | no explicit CodeUri |
autoscale-orchestrator |
22 MB | the #637 binary — untracked, still built here |
Three classes of junk:
- Stray dev binaries.
go build ./...writes<name>after the module directory. Exactly A 22 MiB compiled binary is tracked in git at lambda/autoscale-orchestrator/autoscale-orchestrator #637's binary. - A redundant nested zip. Each Makefile runs
zip function.zip bootstrap, butsam deployignoresfunction.zipand zips the directory — sofunction.zip, holding a second copy ofbootstrap, is packaged inside the deployment zip. Already compressed, hence near-incompressible: that is why 96 MB of files only squeezed to 75.7 MiB. - GoReleaser's release artifact. The
.goreleaser.yaml:25before-hook writesbootstrapandttl-reaper_lambda_linux_arm64.zipintolambda/ttl-reaper/(No supported way to run the TTL reaper in your own account, so governed orgs can't have reaper coverage at all #625). After a release build, that zip is in the CodeUri set too.
The part that matters more than size
lambda/ttl-reaper/Makefile:50-53 generates .deploy-params.yaml inside the CodeUri: . directory, immediately before sam deploy, holding every deploy parameter including NotifyUrl — which the Makefile's own comment (line 55) calls "a Slack webhook secret". Because SAM's walk includes dotfiles, that file is uploaded into the deployment package, readable by anyone with lambda:GetFunction.
To be precise about severity: nothing is leaked right now. The local file's NotifyUrl is empty (0 matches for hooks.slack.com). But make deploy NOTIFY_URL=https://hooks.slack.com/... is the documented usage (Makefile:14), so this is a live trap rather than a past incident. Whether a webhook was ever passed on a real deploy is worth settling — if so it is sitting in the deployed package and should be rotated.
The repo is public, so the .go sources being shipped is not itself a disclosure.
Fix
Build into a dedicated build/ subdirectory holding only bootstrap, and point CodeUri explicitly at it in all three templates. The guarantee is structural: if the directory holds one file, the zip holds one file, regardless of what SAM filters.
sam build + Metadata: BuildMethod: makefile is the AWS-documented route and would also work, but it changes the deploy workflow and these Makefiles encode hard-won invocations — notably ttl-reaper's file://-params-file workaround for sam's parameter-overrides regex (Makefile:25-32). A CodeUri change plus a build directory gets the same result with a much smaller blast radius on a deploy path that touches a live production reaper.
Plus a drift gate asserting that every SAM template sets CodeUri explicitly and never to ., that the directory contains only bootstrap, and that .deploy-params.yaml is never inside a CodeUri directory.
Not in scope
- Shrinking already-deployed packages — a redeploy does that.
- The
deploy.shlambdas (dashboard-api, dashboard-websocket*, alert-*). They useaws lambda update-function-code --zip-filewith an explicit zip and are already narrow. This is specific to the three SAM ones. - A real
sam deployas verification: that touches the live production reaper, so it stays an explicit, separate action.
Activity
scttfrdmn commentedon Oct 3, 2026
Correcting two numbers in the issue body before they get quoted. I measured rather than inferred, and one of my claims was wrong.
I wrote that the reaper's real artifact is "roughly the 7 MiB the autoscale function shows" and called it a ">10x inflation". That inferred the reaper's binary size from a different function's, which was unfounded — the reaper has far more dependencies. Measured by driving SAM's own
make_zip_with_permissionsover the fixedbuild/directory:bootstrapttl-reaperautoscale-orchestratorpipeline-orchestratorSo the real numbers:
bootstrappackage (a fresh build zips to 7.8 MiB). Its last deploy must have run from a clean directory. The exposure there is latent — the next deploy from a dirty tree would inflate it — not active. The issue body implied otherwise.What is unchanged: the mechanism (
os.walkwith no filtering, no.samignore, dotfiles included), the.deploy-params.yamltrap, andpipeline-orchestrator's implicit-cwdpackaging. The fix also now has a hard guarantee rather than an estimate —entries=1, verified against SAM's real zipper, for all three.fix(reaper): read the live stack before deploying, so unspecified par…
chore(release): v0.117.0
feat(reaper): report version skew between the CLI and a deployed reap…