Skip to content

Commit f5a5cb4

Browse files
committed
Refuse to deploy a package missing a vendored module
A manual deploy today shipped the new lambda_function.py with a package built from the old requirements.txt. The zip had no 'github' module, so every invocation died at import with Runtime.ImportModuleError -- dropping all webhook payloads, not just the log downloads -- until it was rolled back. make prepare now starts from clean so a stale packages/ or zip cannot leak into the artifact, and verifies the built zip actually contains every module lambda_function.py imports before deploy can run. Also flag in the README that make deploy is immediately live: the API Gateway integration points at the unqualified function, so update-function-code goes straight to $LATEST. The publish-a-version steps in that doc no longer match how this is wired.
1 parent d5aa1c5 commit f5a5cb4

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
ZIP := github-status-test-deployment.zip
2+
# Third-party modules lambda_function.py imports. The built zip is checked for
3+
# these before it can be deployed: a package missing a dependency fails at
4+
# import, which drops every event the webhook sends -- not just the log
5+
# download -- and update-function-code publishes straight to $LATEST, which is
6+
# what API Gateway invokes.
7+
VENDORED := boto3 requests github
8+
19
# The lambda runs on python3.9/x86_64. cryptography ships compiled wheels, so
210
# pin the target platform rather than inheriting whatever python the CI runner
311
# happens to default to -- otherwise the zip gets wheels the runtime can't load.
4-
prepare:
12+
# Starts from clean so a stale packages/ or zip can't leak into the artifact.
13+
prepare: clean
514
mkdir -p ./packages
615
pip install --target ./packages \
716
--platform manylinux2014_x86_64 --python-version 3.9 \
817
--implementation cp --only-binary=:all: --no-compile \
918
-r requirements.txt
10-
cd packages && zip -r ../github-status-test-deployment.zip .
11-
zip -g github-status-test-deployment.zip lambda_function.py
19+
cd packages && zip -r ../$(ZIP) .
20+
zip -g $(ZIP) lambda_function.py
21+
$(MAKE) verify
22+
23+
verify:
24+
@for m in $(VENDORED); do \
25+
unzip -l $(ZIP) | grep -qE " $$m/__init__\.py$$" \
26+
|| { echo "ERROR: '$$m' missing from $(ZIP), refusing to deploy"; exit 1; }; \
27+
done
28+
@echo "verified: $(ZIP) contains $(VENDORED)"
1229

1330
deploy: prepare
14-
aws lambda update-function-code --function-name github-status-test --zip-file fileb://github-status-test-deployment.zip
31+
aws lambda update-function-code --function-name github-status-test --zip-file fileb://$(ZIP)
1532

1633
clean:
17-
rm -rf github-status-test-deployment.zip packages
34+
rm -rf $(ZIP) packages

aws/lambda/github-status-test/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ Notes on the app path:
3030

3131
### Deployment
3232

33+
> **`make deploy` is immediately live in production.** The API Gateway integration currently points at
34+
> the unqualified function (`:function:github-status-test/invocations`), so `update-function-code` puts
35+
> the new code on `$LATEST` and every webhook hits it right away. The publish-a-version steps below are
36+
> stale — they describe pinning the integration to a numbered version, which is not how it is wired
37+
> today, and the resource id is now `xtmtzj` rather than `clc02o`. Until that is fixed, treat any deploy
38+
> as a direct production change: `make prepare` verifies the zip contains every vendored module before
39+
> `make deploy` will run, but there is no staged rollout behind it.
40+
3341
A new version of the lambda can be deployed using `make deploy` and it will be done so automatically by the workflow
3442
`github-status-test-lambda` when a change is committed to main. We have limited capacity for testing this lambda at
3543
the moment, so additional verification steps are needed to get the new deployed version to prod. More tests and guardrails

0 commit comments

Comments
 (0)