Description
Note: this is another open issue on this build error #1840 but there have been no updates since December and there are other behaviors I'm noticing that are not a part of that issue.
Description:
I have a SAM template where I have defined the architecture at arm64
for my functions and for my shared Lambda Layer.
I am working on an Apple Silicon MacBook Pro (arm64 host).
I am installing a private package from CodeArtifact that has a dependency of jsonschema
that has a dependency of pyrsistent
.
The Lambda Layer is configured to use the builder:
SharedLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: !Ref AWS::StackName
ContentUri: ./src/layers/shared
CompatibleArchitectures:
- arm64
CompatibleRuntimes:
- python3.9
Metadata:
BuildMethod: python3.9
If I run sam build
without a container and view the build files in .aws-sam/build
I can see that it compiled for x86 by some of the binaries that are present: pvectorc.cpython-39-x86_64-linux-gnu.so
. The layer's compatibility is clearly set for arm64
.
I then tried to run the build in a container. The Layer pulled the x86_64
image!
I added the package to a requirements file for the Lambda function to compare. It did pull the arm64
, but then it hit the following error:
Error: PythonPipBuilder:ResolveDependencies - {pyrsistent==0.18.1(wheel)}
Running sam build
without using a container yielded the same error.
Switching the Lambda Function to use x86_64
results in a successful build.
I launched a container to test installing the package ( docker run --rm -it build-python3.9:latest-arm64
) and it did so without an issue.
Here's a summary of the sam build
issues:
- Lambda Layer - On an arm64 host builds are locked to x86_64.
- Lambda Layer - Builds are locked to the x86_64 build image even if compatibility is only arm64.
- Lambda Function - The build fails at the
pyrsistent
dependency (error above) using the arm64 image or building on an arm64 host. This is NOT reproducible inside the arm64 image or on an arm64 host usingpip
directly.
These issues have halted all attempts to migrate to Graviton for Lambda Functions with my group.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOS 12.3
sam --version
: 1.40.1- AWS region: N/A
Add --debug flag to command you are running