sam local start-api fails to move /var/rapid/aws-lambda-rie-x86_64 in docker image for serverless function #4708
Replies: 21 comments 10 replies
-
Thanks for bringing this to our attention! Could you include a basic sample template, handler, and Dockerfile (and anything else necessary) so that we could reproduce this issue more easily and accurately? |
Beta Was this translation helpful? Give feedback.
-
Yes, I'll give it a look when I'll have time |
Beta Was this translation helpful? Give feedback.
-
I have just run into this issue and it affects TL;DR: Lambda functions default to Linux/x86_64 architecture even when run locally with SAM. On Linux for arm/aarch(64) only the Docker Engine/CE is available to install. Unlike for Docker Desktop, CE doesn't include QEMU emulation configuration for other platforms (specifically Linux/x86_64). Third-party binfmt is needed. This on very light testing appears to resolve the issue for SAM. Longer version: docker ps -a and info shows the command that fails:
Additional environment details:
It is fairly easy to reproduce. Just create the hello-world sam app via
The problem is due to a platform mismatch - attempting to run x86_64 images on arm64 architecture. Ordinarily with Docker Desktop on x86_64 it's possible to emulate other architectures such as arm64. Per the AWS SAM document here https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-linux.html it states:
However, I did find this and have managed to get it working for SAM: https://github.com/tonistiigi/binfmt. |
Beta Was this translation helpful? Give feedback.
-
Hi I am running into same issue, any update on the thread please? |
Beta Was this translation helpful? Give feedback.
-
Same issue, any solution for this problem Note: I can build and deploy to the AWS without errors. However at local the error happen when trigger
|
Beta Was this translation helpful? Give feedback.
-
What is the workaround solution you mentioned in this issue? @jensenmo |
Beta Was this translation helpful? Give feedback.
-
@wangzhe3224 @pub-technology Does the fix I described above not work for you? |
Beta Was this translation helpful? Give feedback.
-
Hi @mjvirt I'm also having this same issue when using an M1 Mac running macOS 13.1. I changed the template.yml Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- arm64 # Update this line for it to work locally |
Beta Was this translation helpful? Give feedback.
-
Hi @chrisrhymes and others, maybe I wasn't clear in my original message above, but this last line works: I did find this and have managed to get it working for SAM: https://github.com/tonistiigi/binfmt (other CPU architecture emulation on arm64/M1) In other words you can emulate x86_64 on arm64 - and it works fine with SAM/CDK - at least insofar as I've tested it (just use |
Beta Was this translation helpful? Give feedback.
-
Thanks, I should have said before, but I tried running the command, but only for arm64 I just tried the
|
Beta Was this translation helpful? Give feedback.
-
@chrisrhymes I managed to fix this by executing the following commands
|
Beta Was this translation helpful? Give feedback.
-
Got an error from the last command Already downloaded: /Users/haithai/Library/Caches/Homebrew/downloads/563186ab187d77b0c27b2db3c0f3fc5d25300867da5d18083dd099e13ce4431b--aws-aws-sam-cli-v1.71.0-0-gc681067.tar.gz
Error: aws-sam-cli: SHA256 mismatch
Expected: c27333fb067fd0ffef723c48ed9f26272061d6f3299f5b00ee3d421cc607e0c5
Actual: e05774257d3bbf0080d7d0f0114991bfaf44a9d5bc464cc1427ccc98a4c99cd6
File: /Users/haithai/Library/Caches/Homebrew/downloads/563186ab187d77b0c27b2db3c0f3fc5d25300867da5d18083dd099e13ce4431b--aws-aws-sam-cli-v1.71.0-0-gc681067.tar.gz
To retry an incomplete download, remove the file above I tried to remove and run install again - The error still happening @ixolt |
Beta Was this translation helpful? Give feedback.
-
Thanks @ixolt The new version of AWS SAM CLI - (ノ◕ヮ◕)ノ*:・゚✧ The problem Fixed $ brew uninstall aws-sam-cli
$ brew install rust
$ brew tap aws/tap
$ brew install aws-sam-cli |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue on SAM 1.71.0 (latest) and the emulator install is not resolving it. |
Beta Was this translation helpful? Give feedback.
-
I solved it by
Installing sam via pkg file from https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html |
Beta Was this translation helpful? Give feedback.
-
For an M1 Mac, you can pass the architecture flag Or you could change your Architectures line in your template.yaml like @chrisrhymes described above. I wrote about it a bit more in this Stack Overflow answer: https://stackoverflow.com/questions/75216548/aws-sam-cli-throws-error-error-building-docker-image/75342572#75342572 I think the ideal solution would be for SAM to detect your architecture and act accordingly when creating a Docker image for emulating Lambda locally, while allowing for the Architectures to specify the deployment architecture of the Lambda function. Currently it looks SAM uses the Architectures line for both. |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussions: https://github.com/aws/aws-sam-cli/discussions/4705 Couple of things to consider, specifying the architecture in However, I do like the suggestion on Converting this to a discussion as its broad ranging in scope with respect to architecture of the underlying host. |
Beta Was this translation helpful? Give feedback.
-
Aren't we just talking about taking this |
Beta Was this translation helpful? Give feedback.
-
Same here on an M1. @sriram-mv comment matches my errors. Changing to arm64 and running Java8 which looks to be too old for Arm64. |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, how are people installing SAM CLI that are running into this? If it is by brew, can you uninstall aws-sam-cli and then do I reached out to Homebrew but they added AWS SAM CLI to the core but it's incorrect and removes a file they shouldn't be (the rie version that does not match the system). Which I have a hutch is why this is occurring for folks more and more often, and why we have had a hard time narrowing things down. |
Beta Was this translation helpful? Give feedback.
-
In my case pip but I'm not using mac os to do so. |
Beta Was this translation helpful? Give feedback.
-
Description:
Accessing a lambda using a custom docker image with python awslambdaric fails with:
Steps to reproduce:
Create a serverless function with a custom docker image that uses awslambdaric try to access it through an HttpApi locally.
Observed result:
Expected result:
Should just work or tell how to fix the issue with moving rapid/aws-lambda-rie
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.50.0Beta Was this translation helpful? Give feedback.
All reactions