Feature/lambda architecture param#350
Conversation
Allow customers to select arm64 or x86_64 for Lambda container images in the unified pattern. Defaults to arm64 (Graviton) for best price-performance. Use x86_64 when custom base images only support AMD64. Changes: - template.yaml: Add LambdaArchitecture parameter, pass to PATTERNSTACK - patterns/unified/template.yaml: Add parameter, replace hardcoded Architectures on all 15 Lambda functions with !Ref LambdaArchitecture - Dockerfile.optimized: Accept BASE_IMAGE_SUFFIX build arg to select base image architecture - buildspec.yml, buildspec-bda.yml, buildspec-pipeline.yml: Map LAMBDA_ARCHITECTURE env var to Docker --platform flag
- Add missing -f Dockerfile.optimized and --build-arg BASE_IMAGE_SUFFIX to buildspec-bda.yml and buildspec-pipeline.yml (consistency with main buildspec.yml) - Add LambdaArchitecture to CloudFormation console ParameterGroups under "Advanced - Container Images"
Docker requires ARGs used in FROM to be declared before the first FROM (global scope) for multi-stage builds. Move the ARG declaration to the top so it's available to both builder and runtime stages.
|
AI review identifies 1 blocker and a few suggestions.. Findings 🟡 Should fix — CHANGELOG.md — No entry under [Unreleased]. This is a user-facing parameter; the repo convention (and pr-review/documentation skills) requires a changelog entry. Add an ### Added bullet. 🟡 Should fix (dead code) — patterns/unified/buildspec-bda.yml and patterns/unified/buildspec-pipeline.yml — These two files are not referenced anywhere in the repo (only patterns/unified/buildspec.yml is wired into DockerBuildProject and publish.py/idp_sdk). The PR not only adds the arch mapping here but also makes a functional change — switching the BDA build from per-function build context ("${func_path}", no -f) to the shared Dockerfile.optimized with --build-arg FUNCTION_PATH and context .. Since these files are orphaned, the change is untested and ships confusion. Recommend either (a) deleting both dead buildspecs in a separate cleanup, or (b) at minimum noting in the PR that they're unused. The change itself is more correct than the old form (BDA dirs have no Dockerfile), which suggests these files were stale leftovers from the pattern consolidation. 🟢 Nice to have — Dockerfile.optimized:4 — The CKV_DOCKER_3 checkov-skip reason still hardcodes "public.ecr.aws/lambda/python:3.12-arm64". Now that the suffix is parameterized, update the comment to 3.12-${BASE_IMAGE_SUFFIX} to avoid drift. |
|
Note - to reduce turnaround time, you can easily run your own PR review using the claude or cline skill in the repo.. Just start claude code in the repo root, and ask 'Review PR ' |
|
Bob, I swear, I did use the PR review skill before submitting PR. |
- Add LambdaArchitecture to DockerBuildRun properties so arch-only updates trigger a CodeBuild rebuild (fixes exec format error) - Add CHANGELOG entry under [Unreleased] - Fix Dockerfile checkov comment to reference parameterized image suffix - Add NOTE comments to unused buildspec-bda.yml and buildspec-pipeline.yml clarifying they are not referenced by the main stack
Resolve CHANGELOG.md conflict: keep both our architecture entry and upstream's VPC support + presigned URL entries under [Unreleased].
|
feat: add LambdaArchitecture parameter for configurable CPU architecture
Body
Summary
Adds a
LambdaArchitectureparameter that allows customers to selectarm64orx86_64for all Lambda container images in the unified pattern. Defaults toarm64(Graviton) for best price-performance. Usex86_64when deploying with custom base images that only support AMD64.Previously, the architecture was hardcoded to
arm64across 15 Lambda functions, the Dockerfile, and all three buildspec files. Customers using internal artifact repositories with x86_64-only base images had to manually patch multiple files to switch architectures.Usage
The parameter appears in the CloudFormation console under "Advanced - Container Images".
How it flows
Changes
Backward compatibility
Tested
Both architectures deployed and verified end-to-end (us-east-1, `DeployInVPC=true`):
arm64 (default):
x86_64: