-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(lambda-python): arm64 architecture is not respected #18696
Comments
Managed to successfully executed code build step with pipelines deployed with cdk |
Although in such case...lambda bundle is empty. |
If the Docker image is built on an M1 chip and uploaded to be deployed by Fargate or another similar AWS service then you’ll notice this container error: standard_init_linux.go:228: exec user process caused: exec format error There’s a couple ways to work around this. You can either:
docker buildx build --platform=linux/amd64 -t image-name:version .
|
Yeah but the point in here is I am not using Fargate. |
Are you building with an M1 chip? |
How can I know that? I just setup |
The image is built locally on the computer you're running |
Locally I am building lambda using
Which was my vague attempt to point that logs and situation happens within |
Or in other words, I am not deploying my stacks thus lambda from local machine (my laptop). I am using |
Oh gotcha. Let me try to reproduce this on my end. I'll get back to you soon. |
Ok I was able to reproduce your issue and found a solution: Try updating the PythonFunction's runtime to use ARM 64 Python. i.g. fn_python.PythonFunction(
self,
'ARM',
entry='lambda',
runtime=fn.Runtime('python3.9:latest-arm64', fn.RuntimeFamily.PYTHON), # <-- specify custom runtime
architecture=fn.Architecture.ARM_64,
) |
@ryparker after some further testing I managed to find out that stacks gets deployed in |
@ryparker shouldn't this actually be |
@ryparker Could you help me with this problem? The following error occurs: Resource handler returned message: "Value python3.9:latest-arm64 at 'runtime' failed to satisfy constraint: Member must satisfy enum value set: [nodejs12.x, python3.6, provided, nodejs14.x, ruby2.7, java11, dotnet6, go1.x, provided.al2, java8, java8.al2, dotnetcore3.1, python3.7, python3.8, python3.9] or be a valid ARN (Service: Lambda, Status Code: 400, Request ID: 3d9ba725-5e91-4195-b289-5c44e4f7d0c2, Extended Request ID: null)" (RequestToken: 2571186d-8ab7-c79a-8b05-4870981b5b74, HandlerErrorCode: InvalidRequest) fn := awslambdapython.NewPythonFunction(stack, jsii.String("ddb-to-opensearch"), &awslambdapython.PythonFunctionProps{
Architecture: awslambda.Architecture_ARM_64(),
Runtime: awslambda.NewRuntime(jsii.String("python3.9:latest-arm64"), awslambda.RuntimeFamily_PYTHON, nil),
Entry: jsii.String(codeDir),
LogRetention: awslogs.RetentionDays_ONE_MONTH,
}) |
@hxy1991 This is a different error from the one OP posted and possibly only effects Go. Would you mind opening this in a new issue? |
We solved this problem by setting "Bundling".
|
@hxy1991 but that is a lot of information redundancy in just 8 lines. You've repeated python version 2 times and architecture also 2 times. But it's a workaround of sort. |
This also happens when building lambda layers and the workaround above does not work unfortunately. |
@kornicameister is it possible to create a repo with a project that reproduces this error? I wasn't immediately able to reproduce with the code in the original description. Thanks! |
@mikewrighton sorry but no. I am booked all day long and although still using cdk I have my hands full |
I believe I had a similar issue recently, using typescript, I have a CDK Pipeline with a CodeBuild synth step running The docs (https://docs.aws.amazon.com/cdk/api/v2/docs/aws-lambda-python-alpha-readme.html) say:
This doesn't seem to be the case looking at the code and from my experiments, the CodeBuild image while bundling outputs:
When executing the
And I can actually see the
In the contract of PythonFunction we get BundlingOptions however when bundling BundlingProps is used and it accepts an Creating the Lambda specifying the
But if I force the architecture (note the use of
This works, because the code that decides on the platform is here I think the contract should change, To me it seems like making some small changes here would fix the bug, then there could be a feature request to move
|
With this change, architecture when bundling is inferred from the target architecture of the Lambda function. Closes aws#18696. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
With this change, architecture when bundling is inferred from the target architecture of the Lambda function. Closes aws#18696. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
With this change, architecture when bundling is inferred from the target architecture of the Lambda function. Closes #18696. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
If using @aws-cdk/aws-lambda-python-alpha, you can fix that using PIP_PLATFORM new python_alpha.PythonFunction(this, "MyFunc", {
entry: backendPath(
"lambda/code/directory"
),
runtime: Runtime.PYTHON_3_9,
bundling: {
buildArgs: {
PIP_PLATFORM: "linux_x86_64",
},
},
}); |
What is the problem?
Hey,
Not quite sure if that's a problem with lambda or with codepipelines or at all with cdk.
Been trying to understand it but I just couldn't. Here's what is happening.
I have a
pipelines.CodePipeline
that is configured withcode_build_defaults
that states that I wish to run builds withLinuxBuildImage.AMAZON_LINUX_2_ARM_2
. Obviously later on my lambda functions are configured as follow:That being said I expect that when
CodeBuilds
runs mysynth
step it will run on top ofarm64
and lambda will be build using the same architecture. However in the logs of job I see this:Which seems to contradict to my desire setup of
arm64
. I expectedpublic.ecr.aws/sam/build-python3.9:latest-arm64
would be downloaded instead ofpublic.ecr.aws/sam/build-python3.9:latest
(lack or arm64) in the end.That happens with
cdk 2.8.0
.Last successful build I managed to execute with here was done with
cdk 1.134.0
.PS. My stack defines also
AwsCustomResoure
which is another lambda deployment. Might it be that arm64 and custom resource lambda conflicts each other?Reproduction Steps
CODE is not exactly to be run as-is. It lacks a python lambda code (this is what I have been using) and it lacks proper account and region
What did you expect to happen?
Stack is built correctly inside of deployed pipeline and ARM64 is used.
What actually happened?
Stack fails to built with code linked in first section.
CDK CLI Version
2.8.0
Framework Version
No response
Node.js Version
14.17.5
OS
MacOs BigSur
Language
Python
Language Version
3.10.1
Other information
If I messed something up. I am sorry :(
The text was updated successfully, but these errors were encountered: