aws-sam-cli: [1.33.0] Build gets stuck when using Architectures: ["arm64"]

Description:

We’ve upgraded to aws-sam-cli 1.33.0 in order to take advantage of the new Graviton process when using Lambda functions. After setting Architectures: ["arm64"] in AWS::Serverless::Lambda, the sam build command gets stuck and won’t finish.

2021-10-01 11:31:17,329 | Building codeuri: /home/org.com/user/source/our-project/a-service runtime: python3.9 metadata: {} architecture: arm64 functions: ['LogicalIdOfFunction']
2021-10-01 11:31:17,329 | Waiting for async results
2021-10-01 11:31:17,329 | Building to following folder /home/org.com/user/aws-sam-generated-artifacts/ireland/a-service/LogicalIdOfFunction

Fetching public.ecr.aws/sam/build-python3.9:latest-arm64 Docker container image......
2021-10-01 11:31:18,717 | Mounting /home/org.com/user/source/our-project/a-service as /tmp/samcli/source:ro,delegated inside runtime container

These are the last lines of output. After that, no more logs are generated and sam build gets stuck.

Steps to reproduce:

  1. Upgrade to aws-sam-cli: 1.33.0
  2. Define a AWS::Serverless::Function with Architectures: ["arm64"]
  3. Run sam build --use-container --parallel ...

Observed result:

sam build gets stuck (see the log output above)

Expected result:

sam build executes as expected

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 18.04.5 LTS
  2. sam --version: 1.33.0
  3. AWS region: ireland

Add --debug flag to command you are running

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Stumbled upon this today. Unable to build with from Github Actions with architecture set to arm64.

Reverting back to x86_64 fixes the problem. However, it would be nice to be able to build SAM applications with arm64 from github

@Duchynko and @piersf, In order for multiarchitecture to work with docker we have to enable a setting. I enabled this by running docker run --rm --privileged multiarch/qemu-user-static --reset -p yes and now I am able to build arm_64 lambdas locally. Can you please try it?

@movaid7 Have you tried adding a step before the sam build one? Like so:

# docker setup
- name: Setup Docker for cross architecture build
  run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Has anyone worked this out ?

For those experiencing this… It may simply be that building in the container is atrociously slow due to QEMU emulation being required. To confirm and monitor progress: sam build --use-container --debug will help troubleshoot if it is truly hanging or simply taking a long time to compile dependencies on emulated ARM.

@movaid7 Hey for your question we do have very different images tagged with latest (or latest-x86_64) and latest-arm64 to support different architectures. So when you see this message it is pulling the right image that is set up for arm64. Can you specify more information on your execution, maybe the docker version? If you are still seeing this problem we will try to help you with that but so far I couldn’t exactly understand the root cause of your issue and could not yet reproduce it!

We had updated our doc but only on this page: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-linux.html

We will be looking at making it more visible. Thanks!