Skip to content

Add reusable workflows to build and deploy a Lambda zip - #46

Merged
ToreMerkely merged 2 commits into
mainfrom
7913-lambda-golden-pipeline
Nov 10, 2026
Merged

ToreMerkely merged 2 commits into
mainfrom
7913-lambda-golden-pipeline

Conversation

@ToreMerkely

Copy link
Copy Markdown
Contributor

What changed

Adds build-lambda.yml and deploy-lambda.yml, the golden pipeline for Lambda zip packages: the repository that holds a function's source builds, attests and deploys it. Adds the #7913 handover.

Part of kosli-dev/server#7913

Why

apply.yml attests each Lambda's fingerprint to the Terraform apply's trail, whose pull request reviewed the Terraform and not necessarily the code. Building in the source repository puts the package on a trail with the PR, tests and dependencies that produced it, so the SDLC controls can be decided for it.

build-lambda.yml (inputs package_name, source_path, python_version, bundle_kosli_cli, bundled_kosli_cli_version, controls):

  • installs uv.lock or requirements.txt as manylinux wheels for the runtime's Python, with no Docker, and runs pytest when there are test_*.py files;
  • zips with fixed timestamps and sorted entries, so a re-run of the same commit produces the same fingerprint;
  • uploads to lambda-packages-<hash> under <repo>/<package>/<sha>.zip as lambda-package-publisher (terraform-base-infra#1247), refusing to overwrite, and accepting an existing key whose checksum matches;
  • attests the artifact, PR, junit, lockfile, SBOM (syft), SBOM components and runtime to flow <repo>-<package>, trail = commit;
  • calls evaluate-policy.yml with variants: {"SDLC-CTRL-0004": "zip"} (kosli-dev/sdlc-policies#59, #60), passing SDLC-CTRL-0008's params only when it is evaluated.

deploy-lambda.yml (inputs s3_key, fingerprint, function_name, environments, github_environment, role_name): fetches the accounts from terraform-deploy-matrix, waits for one approval job when github_environment is set, then per account downloads the package, checks its SHA-256 and runs update-function-code --publish. Deploys pass the zip's bytes, so Lambda never reads the bucket.

Verification

  • actionlint 1.7.7 on both workflows; make test passes (102 tests).
  • The build's install, copy and zip steps, run twice locally on kosli-queue-sampler, produced byte-identical zips containing main.py and redis.
  • The params filter, run locally, leaves out SDLC-CTRL-0008 when it is not in controls.
  • Nothing has run in GitHub Actions yet: the first caller is the pilot.

Follow-ups

Recorded in the handover's Next Steps:

  • The pilot, kosli-queue-sampler in terraform-server: boto3 declared, a deploy role per account, ignore_changes on the function's code, and a check of the version-qualified EventBridge permission.
  • lambda-package-publisher's trust on job_workflow_ref is verified only by the first build run.
  • README documentation of the two workflows.

🤖 Generated with Claude Code

build-lambda.yml runs in the repository that holds a function's source:
it installs the locked dependencies as Lambda-platform wheels, runs the
tests, zips the package reproducibly, uploads it write-once to the
package bucket, attests it with its pull request, tests, lockfile, SBOM
and runtime, and evaluates the SDLC controls, SDLC-CTRL-0004 with its zip
variant. deploy-lambda.yml downloads that package, checks its SHA-256 and
swaps a function's code in every account of an environment type, behind
one GitHub environment approval when one is named.

Adds the handover for kosli-dev/server#7913.

See kosli-dev/server#7913

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ToreMerkely
ToreMerkely merged commit 4a67e68 into main Nov 10, 2026
1 check passed
@ToreMerkely
ToreMerkely deleted the 7913-lambda-golden-pipeline branch November 10, 2026 14:47
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.

2 participants