(aws-lambda): Ability to specify CPU architecture for building image
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### 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:
```
builder_options = BundlingOptions(
command=packaging_instructions,
image=aws_lambda.Runtime.JAVA_11.bundling_image,
user="root",
output_type=BundlingOutput.ARCHIVED,
)
```
Which uses the architecture of the machine I'm building on, I'd like to be able to say something like:
```
builder_options = BundlingOptions(
command=packaging_instructions,
image=aws_lambda.Runtime.JAVA_11.bundling_image_for(aws_lambda.Architecture.X86_64),
user="root",
output_type=BundlingOutput.ARCHIVED,
)
```
### 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
```
builder_options = BundlingOptions(
command=packaging_instructions,
image=aws_lambda.Runtime('java11:latest-x86_64', aws_lambda.RuntimeFamily.JAVA).bundling_image,
user="root",
output_type=BundlingOutput.ARCHIVED,
)
```
As a workaround, but it'd be nice to be able to use the `aws_lambda.Runtime` and `aws_lambda.Architecture` constants.
I learned about this workaround from https://github.com/aws/aws-cdk/issues/18696#issuecomment-1027322761
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### 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
Contributor guide
Research direction
Start by locating the aws_lambda.Runtime bundling_image API, RuntimeFamily.JAVA definitions, BundlingOptions, and Architecture constants referenced in the issue. Trace how the Java bundling image is selected, then verify that callers can request an x86_64 image while existing machine-architecture behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, python, typescript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100