-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(lambda): docker platform for architecture #16858
Conversation
Add a `dockerPlatform` property in `Architecture` and use it to pass the correct `platform` when bundling in a container in `aws-lambda-nodejs`, `aws-lambda-go` and `aws-lambda-python`.
@@ -117,6 +122,7 @@ export class Bundling implements cdk.BundlingOptions { | |||
...props.buildArgs ?? {}, | |||
IMAGE: Runtime.GO_1_X.bundlingImage.image, // always use the GO_1_X build image | |||
}, | |||
platform: props.architecture.dockerPlatform, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need to remove the GOARCH
environment variable on line 112 above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -104,7 +109,7 @@ export class Bundling implements cdk.BundlingOptions { | |||
const environment = { | |||
CGO_ENABLED: cgoEnabled, | |||
GO111MODULE: 'on', | |||
GOARCH: 'amd64', | |||
GOARCH: props.architecture.dockerPlatform.split('/')[1], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@corymhall what about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@@ -10,23 +10,29 @@ export class Architecture { | |||
/** | |||
* 64 bit architecture with the ARM instruction set. | |||
*/ | |||
public static readonly ARM_64 = new Architecture('arm64'); | |||
public static readonly ARM_64 = new Architecture('arm64', 'linux/arm64'); | |||
|
|||
/** | |||
* Used to specify a custom architecture name. | |||
* Use this if the architecture name is not yet supported by the CDK. | |||
* @param name the architecture name as recognized by AWS Lambda. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstring for param
*/ | ||
public readonly dockerPlatform: string; | ||
|
||
private constructor(archName: string, dockerPlatform?: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For safety, maybe make explicit:
private constructor(archName: string, dockerPlatform?: string) { | |
private constructor(archName: string, dockerPlatform: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this resolve #12472?
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Add a `dockerPlatform` property in `Architecture` and use it to pass the correct `platform` when bundling in a container in `aws-lambda-nodejs`, `aws-lambda-go` and `aws-lambda-python`. Note that the SAM build images (`public.ecr.aws/sam/build-<runtime>`) are now multi-arch. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ker images (#20439) This PR adds support for specifying the desired build platform when building docker images (ie: build an arm64 image on an amd64/x86_64 host). Closes #12472 This PR does NOT touch Lambda builders, only ECR assets. #16770 attempted to implement support for ECR and Lambda but was abandoned. Meanwhile #16858 implemented lambda platform support. This implements the ECR side I have run `yarn integ` ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/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/master/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*
Add a
dockerPlatform
property inArchitecture
and use it to pass thecorrect
platform
when bundling in a container inaws-lambda-nodejs
,aws-lambda-go
andaws-lambda-python
.Note that the SAM build images (
public.ecr.aws/sam/build-<runtime>
) are nowmulti-arch.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license