Skip to content

aws-lambda-nodejs: Docker bundling fails with bun on ARM64 architecture - @oven/bun-linux-x64-baseline not found #35534

@dsilbergleithcu-godaddy

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

  1. Set up GitHub Actions workflow running on AWS Graviton instance
  2. Use a NodejsFunction with bun package manager (Docker bundling occurs by default)
  3. The Docker build fails during the bun installation step
  4. 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

  1. Update bun version to a newer release with better ARM64 support
  2. 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
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions