Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different architecture support for Lambda functions #2166

Closed
1 task done
zachjonesnoel opened this issue Sep 30, 2021 · 6 comments
Closed
1 task done

Different architecture support for Lambda functions #2166

zachjonesnoel opened this issue Sep 30, 2021 · 6 comments

Comments

@zachjonesnoel
Copy link

zachjonesnoel commented Sep 30, 2021

Describe your idea/feature/enhancement

Provide a clear description.

AWS Lambda recently announced about Lambda functions powered by AWS Graviton2 processor where it's mentioned that AWS SAM would also support the different architectures for the Lambda function. So that it's easier to deploy with SAM build CLI command.
Just searched for the options currently there was none and didn't find in the issue list so raising it.

Proposal

A new parameter on AWS SAM should be able define different architectures -

  • arm64 (Recently announced)
  • x86_64
  Parameters:
     LambdaArchitecture:
        Type: String
        Default: x86_64
        AllowedValues:
             - x86_64
             - arm64
    Description: Lambda function Architecture type.

Sample parameter Architecture which accepts either x86_64 or arm64

        Type: AWS::Serverless::Function
        Properties:
              Architecture : !Ref LambdaArchitecture

Add details on how to add this to the product.

Things to consider:

Additional Details

@Phuurl
Copy link
Contributor

Phuurl commented Sep 30, 2021

Looks like support for this has been added in 1.39.0 (Release: https://github.com/aws/serverless-application-model/releases/tag/v1.39.0 Commit: 77deed7 #2164), just not available in the main released version or documented yet.

Edit: Appears to have shipped in SAM CLI 1.33.0

@zachjonesnoel
Copy link
Author

Thanks @Phuurl for the update. Let me check it out.

@bitconym
Copy link

bitconym commented Oct 1, 2021

I tried using the Architectures and CompatibleArchitectures property and set it to arm64 but running the command sam build --use-container gets stuck at mounting:

Mounting /path/to/lambda as /tmp/samcli/source:ro,delegated inside runtime container

After I removed property Architectures: [arm64] and CompatibleArchitectures: [arm64] for the layer, the lambda used the default arch x86_64 and the sam build passed. I have no idea why this happens.
arm64 - sam build uses the Docker image: public.ecr.aws/sam/build-nodejs14.x:latest-arm64
x86_64 - sam build uses the Docker image: public.ecr.aws/sam/build-nodejs14.x:latest-x86_64

I'm using the latest SAM CLI, version 1.33.0.

@mgrandis
Copy link
Contributor

mgrandis commented Oct 5, 2021

@imjustd
Thank you for your feedback.
Are you using Linux?
If so, you have to run this command to be able to run Docker image with a different architecture than your host is running:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

We added it to the docs on this page (but we may need to add it at other places to make it more visible):
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-linux.html

@bitconym
Copy link

bitconym commented Oct 5, 2021

@mgrandis yes I use Linux. That actually did the trick, thanks for posting it! But I couldn't find it, maybe good to add this to the SAM CLI when invoked to give a warning if trying to build arm64 lambda. Or really try to make it more visible and place it in more places.

@jfuss
Copy link
Contributor

jfuss commented Oct 12, 2021

This was released in https://github.com/aws/aws-sam-cli/releases/tag/v1.33.0 of SAM CLI and is already available in SAM.

If you are running into troubles with SAM CLI support, please cut a new issue to that repo here. If there is something off in the SAM Spec, please create a new issue in this repo here

Closing as this is already supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants