Skip to content

(aws-lambda): Ability to specify CPU architecture for building image #20907

@SamStephens

Description

@SamStephens

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 #18696 (comment)

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-lambdaRelated to AWS Lambdaeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions