-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Describe the bug
The aws-lambda-nodejs construct fails to build when using Docker bundling on AWS Graviton instances running GitHub Actions workflows due to a bun installation failure. The Docker build process attempts to install [email protected] but fails because it cannot find the @oven/bun-linux-x64-baseline package, indicating an architecture mismatch in the CI environment.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
The Docker build should successfully install bun in GitHub Actions workflows running on AWS Graviton instances, consistent with local development behavior.
Current Behavior
The build fails on AWS Graviton instances in GitHub Actions because npm tries to install the x64-specific bun package (@oven/bun-linux-x64-baseline) instead of the ARM64 equivalent, while the same code works fine on local M4 MacBook Pro.
Reproduction Steps
- Set up GitHub Actions workflow running on AWS Graviton instance
- Use a
NodejsFunctionwith bun package manager (Docker bundling occurs by default) - The Docker build fails during the bun installation step
- Same code works fine when run locally on M4 MacBook Pro
Example code:
const customResourceFunction = new NodejsFunction(
this,
"CustomResourceFunction",
{
runtime: lambda.Runtime.NODEJS_LATEST,
entry: path.join(__dirname, "lambda", "handler.ts"),
handler: "handler",
timeout: Duration.minutes(15),
bundling: {
externalModules: ["aws-sdk"],
},
},
);
Possible Solution
- Update bun version to a newer release with better ARM64 support
- Use official bun installer instead of npm:
RUN curl -fsSL https://bun.sh/install | bash -s "bun-v1.1.30" && \ ln -s /root/.bun/bin/bun /usr/local/bin/bun
- Add conditional installation based on architecture detection in CI environments
Additional Information/Context
Complete Error Output from GitHub Actions:
#7 [ 4/12] RUN npm install --global [email protected]
#7 54.19 npm error code 1
#7 54.19 npm error path /var/lang/lib/node_modules/bun
#7 54.19 npm error command failed
#7 54.19 npm error command sh -c node install.js
#7 54.19 npm error Failed to find package "@oven/bun-linux-x64-baseline". You may have used the "--no-optional" flag when running "npm install".
#7 54.19 npm error Error: Failed to install package "bun"
#7 54.19 npm error at /var/lang/lib/node_modules/bun/install.js:336:11
#7 54.19 npm error at Generator.throw (<anonymous>)
#7 54.19 npm error at rejected (/var/lang/lib/node_modules/bun/install.js:36:27)
#7 54.19 npm error at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
#7 54.23 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-09-19T16_08_00_975Z-debug-0.log
#7 ERROR: process "/bin/sh -c npm install --global [email protected]" did not complete successfully: exit code: 1
Docker command that failed:
docker build --platform "linux/amd64" --build-arg "IMAGE=public.ecr.aws/sam/build-nodejs18.x" --build-arg "ESBUILD_VERSION=0.21" [path]/aws-cdk-lib/aws-lambda-nodejs/lib
Environment Details:
- Works: M4 MacBook Pro (local development)
- Fails: AWS Graviton instance (GitHub Actions runner)
Root Cause:
The issue is in /packages/aws-cdk-lib/aws-lambda-nodejs/lib/Dockerfile at line 13:
RUN npm install --global [email protected]Workaround:
Use forceDockerBundling: false to use local bundling instead of Docker bundling.
AWS CDK Library version (aws-cdk-lib)
2.215.0
AWS CDK CLI version
2.215.0
Node.js Version
22.12.0
OS
AWS Graviton instance (GitHub Actions), works on macOS (M4 MacBook Pro)
Language
TypeScript
Language Version
No response
Other information
This specifically affects CI/CD pipelines running on AWS Graviton-backed GitHub Actions runners while working fine in local development on Apple Silicon, suggesting a Docker platform detection or environment difference between these ARM64 variants.