asset-staging.ts: target platform ignored when bundling asset #30239
Labels
@aws-cdk/aws-s3-deployment
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
When bundling an asset e.g. in an s3_deployment using docker, the platform property gets ignored. The bundling always takes place on the host's platform.
Expected Behavior
Using
platform: 'linux/amd64'
should bundle for amd64 on M1 and
platform: 'linux/arm64'
should bundle for ARM on amd64 architecture as described in https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html#platform
Current Behavior
platform: 'something'
is silently ignored.Reproduction Steps
Bundle for a s3_deployment like this:
Do a
cdk synthesize
and look into the created output file 'uname-m.out.txt' asset in cdk.out. Whatever you put into 'platform', it always contains your host machine's platform string.Possible Solution
The reason is that the platform given does not get propagated in aws-cdk-lib/core/lib/private/asset-staging.ts when calling image.run().
adding
platform: this.options.platform
at two places fixes the issue.Pull request is on it's way.
Additional Information/Context
No response
CDK CLI Version
2.141.0 (build 3d1c06e)
Framework Version
No response
Node.js Version
v20.11.0
OS
macos 14.4.1 (23E224)
Language
TypeScript
Language Version
No response
Other information
As a sidenote: before changing the platform, the local docker build image, e.g.
public.ecr.aws/sam/build-python3.9:latest
has to be deleted manually usingdocker image rm public.ecr.aws/sam/build-python3.9:latest
. Otherwise docker would use the same image for a different/wrong platform with unwanted behavior.Fixing that is not within the scope of this issue.
The text was updated successfully, but these errors were encountered: