Skip to content

feat(build): Support X86_64 MicrovmImages - #9415

Merged
licjun merged 3 commits into
aws:developfrom
licjun:feat-microvm-image-x86-64
Nov 10, 2026
Merged

licjun merged 3 commits into
aws:developfrom
licjun:feat-microvm-image-x86-64

Conversation

@licjun

@licjun licjun commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Which issue(s) does this change fix?

Follow-up to #9357, which added sam build support for MicrovmImage.

Why is this change necessary?

The MicroVM service now builds X86_64 images: the AWS::Lambda::MicrovmImage CpuConfigurations[].Architecture accepts ARM_64 and X86_64, and the managed base image al2023-1 version 3 supports both. sam build still treated Architecture: X86_64 as unsupported. Building all resources skipped the image, and sam build <image> failed with "unsupported architecture; only ARM_64 is supported by the MicroVM service".

How does it address the issue?

  • SamMicrovmImageProvider maps X86_64 to x86_64, so the image is built for linux/amd64. The cross-architecture warning, the build summary and the JSON output already handle any architecture.
  • An image without CpuConfigurations is still built for arm64. I deployed one with base image version 3 and no CpuConfigurations: the SAM transform wrote CpuConfigurations: [], and the service built the image with cpuConfigurations: [{architecture: ARM_64}].
  • The unsupported-architecture messages now list ARM_64 and X86_64.

What side effects does this change have?

None for ARM_64 or an omitted architecture. sam validate and deployments still reject X86_64 on AWS::Serverless::MicrovmImage until the SAM transform allows it (aws/serverless-application-model#4031) and SAM CLI moves to that aws-sam-translator release. AWS::Lambda::MicrovmImage is not affected by the transform.

Testing

  • Built a template with an X86_64 image and an image without CpuConfigurations on an arm64 host with Docker. The images were linux/amd64 and linux/arm64, and a RUN uname -m step reported x86_64 and aarch64. The build printed the cross-architecture warning for the X86_64 image, and --output json reported x86_64 and arm64.
  • A new integ test, test_build_x86_64_microvm_image, builds an X86_64 image and checks that it is linux/amd64, with and without --use-buildkit. It runs with the other MicrovmImage tests in the build-arm64 integration suite.
  • An invalid value such as RISCV is still skipped when building all resources and fails a targeted build.
  • A new provider unit test checks that X86_64 is extracted as x86_64, and the image is now in the buildable images list. Removing the X86_64 mapping fails it. Unit tests pass (9770, coverage 94.08%).

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The MicroVM service now builds X86_64 images, but sam build treated
CpuConfigurations Architecture X86_64 as unsupported: it skipped the
image when building all resources and failed a targeted build. Accept
X86_64 and build it for linux/amd64. An image without CpuConfigurations
is still built for arm64, which is what the service builds for an empty
list.
@github-actions github-actions Bot added area/build sam build command pr/internal labels Nov 9, 2026
@aws-sam-tooling-bot

aws-sam-tooling-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🧪 Hands-on test: No problems observed in 6 scenarios

Commit 1fe395a · build LambdaToolingHandsOn-Docker:aedb5a4f-18fc-4f7e-b06b-ffef92abf907. The plan's scenarios ran on an isolated build host; a problem is reported only if it reproduced at least twice. Passing scenarios show only that these checks behaved as expected, not that the change is correct.

Scenarios

Scenario Planned check Result Runner's note
S1 Main path: build all resources. The X86_64 image is built for linux/amd64, images with omitted or empty CpuConfiguratio… ✅ pass Host x86_64, Docker 29.9.2. CLI run via samdev (SAM_CLI_DEV=1 entry point). Head: exit=0; summary lists X86Image -> x86image:latest (linux/amd64), DefaultImage and EmptyCpuImage (linux/arm64); RiscvI…
S2 --output json reports architecture x86_64 for the X86_64 image and arm64 for the default images. ✅ pass Head --output json: exit=0, status success, resources X86Image x86_64 x86image:latest, DefaultImage arm64, EmptyCpuImage arm64, no RiscvImage. Base: same but no X86Image entry.
S3 Targeted builds. sam build X86Image now succeeds; sam build RiscvImage still fails, now with the reworded Unsupport… ✅ pass Head: 'build X86Image' exit=0 with 'X86Image -> x86image:latest (linux/amd64)'; 'build RiscvImage' exit=1 with "MicrovmImage 'RiscvImage' is not buildable: unsupported architecture; supported values …
S4 The AWS::Lambda::MicrovmImage type (CodeArtifact.Uri), which the transform doesn't affect, also maps X86_64 to linux/am… ✅ pass AWS::Lambda::MicrovmImage with CodeArtifact.Uri and X86_64. Head: exit=0, summary 'LambdaX86Image -> lambdax86image:latest (linux/amd64)', inspect linux/amd64. Base: exit=0 but image skipped with 'on…
S5 Architecture from a template parameter. X86_64 passed with --parameter-overrides builds amd64. A missing value still gi… ✅ pass Head: --parameter-overrides Arch=X86_64 exit=0, 'ParamImage -> paramimage:latest (linux/amd64)', inspect linux/amd64. Without override: ParamImage not built (exit=0, overall Build Succeeded), warning…
S6 The repo's unit tests for the provider and for MicrovmImage handling in build_context, including the new X86_64 extract… ✅ pass Head: test_sam_microvm_image_provider.py 28 passed (includes test_x86_64_architecture_extracted_from_cpu_configurations; test_get_all_must_return_all_buildable_images lists MicrovmImageWithX86Arch). …
Runner's notes in full
  • S1: Host x86_64, Docker 29.9.2. CLI run via samdev (SAM_CLI_DEV=1 entry point). Head: exit=0; summary lists X86Image -> x86image:latest (linux/amd64), DefaultImage and EmptyCpuImage (linux/arm64); RiscvImage skipped with 'supported values are ARM_64 and X86_64.' Inspect: x86image linux/amd64, default/emptycpu linux/arm64, riscvimage MISSING; container prints x86_64. Cross-arch warning only for the arm64 images. Base: X86Image skipped with 'only ARM_64' message, x86image MISSING; arm64 images built the same.
  • S3: Head: 'build X86Image' exit=0 with 'X86Image -> x86image:latest (linux/amd64)'; 'build RiscvImage' exit=1 with "MicrovmImage 'RiscvImage' is not buildable: unsupported architecture; supported values are ARM_64 and X86_64." Base: both exit=1 with the old 'only ARM_64 is supported by the MicroVM service' wording.
  • S4: AWS::Lambda::MicrovmImage with CodeArtifact.Uri and X86_64. Head: exit=0, summary 'LambdaX86Image -> lambdax86image:latest (linux/amd64)', inspect linux/amd64. Base: exit=0 but image skipped with 'only ARM_64' warning, inspect MISSING.
  • S5: Head: --parameter-overrides Arch=X86_64 exit=0, 'ParamImage -> paramimage:latest (linux/amd64)', inspect linux/amd64. Without override: ParamImage not built (exit=0, overall Build Succeeded), warning "MicrovmImage 'ParamImage' has unsupported Architecture 'Arch'; supported values are ARM_64 and X86_64. 'Arch' is a template parameter with no value; provide it via --parameter-overrides." Base: Arch=X86_64 skipped with 'only ARM_64' warning, inspect MISSING; no-override case gives the old wording plus the same parameter hint.
  • S6: Head: test_sam_microvm_image_provider.py 28 passed (includes test_x86_64_architecture_extracted_from_cpu_configurations; test_get_all_must_return_all_buildable_images lists MicrovmImageWithX86Arch). test_build_context.py -k microvm: 15 passed, 110 deselected. Both exit 0.

🤖 Automated hands-on test — not a review approval · model claude-opus-5.5 · Kiro kiro-cli 2.33.1 · build LambdaToolingHandsOn-Docker:aedb5a4f-18fc-4f7e-b06b-ffef92abf907 · commit 1fe395a

History (3)
Commit Result When (UTC) Build
1fe395a No problems observed 2026-11-09 23:02 LambdaToolingHandsOn-Docker:aedb5a4f-18fc-4f7e-b06b-ffef92abf907
462ba9e Problems reproduced: X86_64 MicrovmImage build fails with 'exec format error' when an arm64 copy of …; In a mixed-architecture build, DefaultImage is reported as linux/arm64 in the s…; Changing CpuConfigurations from ARM_64 to X86_64 reports (linux/amd64) but the … 2026-11-09 21:54 LambdaToolingHandsOn-Docker:69193fae-76b9-4a09-a5e8-ea0c0ce959af
9d2915d Problems reproduced: Mixed-arch build-all: DefaultImage (arm64) is built from the amd64 base image p… 2026-11-09 21:40 LambdaToolingHandsOn-Docker:2d776af0-9e9c-4fef-8c6f-f472a1b48c9d

@aws-sam-tooling-bot aws-sam-tooling-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 Hands-on test reproduced 1 new problem on commit 9d2915d. Commands and evidence are in the hands-on comment.

  1. [BUG] Mixed-arch build-all: DefaultImage (arm64) is built from the amd64 base image pulled for the X86_64 image, while the summary says linux/arm64 · medium · samcli/lib/build/app_builder.py:1248

🤖 Automated hands-on test — not a review approval

Check that CpuConfigurations Architecture X86_64 is extracted as x86_64,
and that such an image is returned as buildable.

@aws-sam-tooling-bot aws-sam-tooling-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 Hands-on test reproduced 3 new problems on commit 462ba9e. Commands and evidence are in the hands-on comment.

  1. [BUG] X86_64 MicrovmImage build fails with 'exec format error' when an arm64 copy of its base image is cached locally (e.g. after an ARM_64 build) · medium
  2. [BUG] In a mixed-architecture build, DefaultImage is reported as linux/arm64 in the summary and JSON but is built as linux/amd64 · medium
  3. [BUG] Changing CpuConfigurations from ARM_64 to X86_64 reports (linux/amd64) but the rebuilt image stays linux/arm64 (Docker layer cache reused) · medium

🤖 Automated hands-on test — not a review approval

Build an X86_64 MicrovmImage and check that the image is linux/amd64.
The fixture uses a base image that no arm64 test uses, so the classic
builder cannot reuse a base image cached for another platform.
@licjun

licjun commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Response to the hands-on findings on 462ba9e and 9d2915d: all four have one root cause, and it predates this PR.

Root cause. With the classic (non-BuildKit) builder and the classic image store, Docker reuses a base image tag that is already cached locally, even when it was pulled for another platform, instead of resolving it for the requested platform. The second image in a mixed-architecture build then gets the first image's base. That explains DefaultImage being built as linux/amd64, the X86_64 build hitting exec format error with an arm64 base cached, and the ARM_64 to X86_64 switch hitting Using cache and keeping an arm64 image.

Where it reproduces. Same templates built against Docker-in-Docker daemons with the classic overlay2 store, with the base image removed before each run:

Build Docker 26.1.4 Docker 29.9.3
MicrovmImage X86_64 + default, this PR both correct default image is linux/amd64
PackageType: Image functions, x86_64 then arm64, develop both correct arm64 function is linux/amd64
PackageType: Image functions, arm64 then x86_64, develop both correct x86_64 function is linux/arm64
Either, with --use-buildkit both correct

It does not reproduce with the containerd image store (the Docker Desktop default), which keeps every platform of a tag. So PackageType: Image functions already have the same problem on develop; this PR makes MicrovmImage templates hit it once they mix architectures.

Plan. --use-buildkit avoids it today. A separate PR will fix it for both resource types: after the build, compare the image's architecture with the requested platform in _build_lambda_image and _build_microvm_image, and fail with a message that suggests --use-buildkit or removing the cached base image, instead of reporting the wrong platform. This PR stays scoped to enabling X86_64. The new X86_64 integ test uses a base image that no arm64 test uses, so it does not depend on that fix. The latest run on 1fe395a reports no problems.

@licjun
licjun marked this pull request as ready for review November 10, 2026 00:02
@licjun
licjun requested a review from a team as a code owner November 10, 2026 00:02
@licjun
licjun merged commit f06cf03 into aws:develop Nov 10, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants