-
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
(aws-lambda): Ability to specify CPU architecture for building image #20907
Comments
Actually, my suggestion
Is based on a Runtime being architecture independent. But the workaround
Implies that a Runtime can have an Architecture. Which is a little odd. |
Based on [this](#16770) PR Add the missing part to add platform support when using lambda `fromImageAsset` As we are not allowed to specify `platform` flag for `DockerImageAsset`, users deploying cdk on x86_64 platform will not be able to bundle lambda.DockerImageFunction for the new arm64 architecture. Similarly, users deploying cdk on arm64 architecture like Mac M1 will not be able to bundle images for AWS Fargate, which is x86_64 only. # builder experience with aws-lambda For x86_64 users deploying Lambda functions with container runtime on Lambda Graviton2(arm64) from local container image assets with multi-architecture docker base images. Specify the platform to ensure the image would be built for ARM64 architecture. ``` new DockerImageFunction(stack, 'Lambda', { code: DockerImageCode.fromImageAsset(path.join(__dirname, 'docker-arm64-handler')), architecture: Architecture.ARM_64, }); ``` Fixes: #12472, #20907 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Based on [this](aws#16770) PR Add the missing part to add platform support when using lambda `fromImageAsset` As we are not allowed to specify `platform` flag for `DockerImageAsset`, users deploying cdk on x86_64 platform will not be able to bundle lambda.DockerImageFunction for the new arm64 architecture. Similarly, users deploying cdk on arm64 architecture like Mac M1 will not be able to bundle images for AWS Fargate, which is x86_64 only. # builder experience with aws-lambda For x86_64 users deploying Lambda functions with container runtime on Lambda Graviton2(arm64) from local container image assets with multi-architecture docker base images. Specify the platform to ensure the image would be built for ARM64 architecture. ``` new DockerImageFunction(stack, 'Lambda', { code: DockerImageCode.fromImageAsset(path.join(__dirname, 'docker-arm64-handler')), architecture: Architecture.ARM_64, }); ``` Fixes: aws#12472, aws#20907 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Is it possible to specify the architecture on the bundling image in cdk? Think i'm hitting into this problem. Pydantic core is throwing errors in my deployment as it seems to not be matched up for the architecture and I think it may be related to this. I did swap everything to arm64 and had it working when using cdk deploy from my mac but now I'm deploying from github actions rather than my local machine it is breaking and i'm wondering if it is doing something different there that may be related to this. It suggests here that it is possible to specify architecture in bundling but I don't see it when i go to the actual BundlingOptions page https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda_python_alpha/PythonLayerVersion.html |
@HeskethGD have you solved your issue? Seems I faced the same) |
@HeskethGD @tolikkostin the workaround to specify an architecture is right in the original issue description. Rather than using an image constant like
Then use those bundling options as a parameter to |
@SamStephens Thanks that works for me. |
Describe the feature
I'd like the ability to specify usage of a bundling image for a particular CPU architecture. As an example, for a Java build, rather than saying:
Which uses the architecture of the machine I'm building on, I'd like to be able to say something like:
Use Case
We use a Java library that doesn't work on ARM. We deploy to x86_64 Lambda, so this shouldn't be a problem. But in order to ensure builds on M1/M2 Mac work, we need to force the Docker image we use for Java to be an x86_64 image.
I'm currently using
As a workaround, but it'd be nice to be able to use the
aws_lambda.Runtime
andaws_lambda.Architecture
constants.I learned about this workaround from #18696 (comment)
Proposed Solution
No response
Other Information
No response
Acknowledgements
CDK version used
2.26.0, Python
Environment details (OS name and version, etc.)
Ubuntu 20.04 on WSL 2 within Windows 10.0.19044
The text was updated successfully, but these errors were encountered: