Skip to content

Commit 91bec88

Browse files
authored
fix(core): platform is ignored during asset bundling (#33865)
### Issue # (if applicable) Closes #30239 ### Reason for this change The ```BundlingOptions``` ```platform``` property is not being used in ```AssetBundlingBindMount``` or ```AssetBundlingVolumeCopy``` and is not passed as a command line option to Docker. Fix makes the platform property work as described in ```BundlingOptions``` documentation: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html#platform. ### Description of changes added ```platform: this.options.platform``` to ```AssetBundlingBindMount.run``` and ```AssetBundlingVolumeCopy.run``` in ```packages/aws-cdk-lib/core/lib/asset-staging.ts``` ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Added platform property to unit and integration tests * ```packages/aws-cdk-lib/core/test/private/asset-staging.test.ts``` * ```packages/@aws-cdk-testing/framework-integ/test/aws-s3-assets/test/integ.assets.bundling.docker-opts.ts``` ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent eb5e688 commit 91bec88

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-s3-assets/test/integ.assets.bundling.docker-opts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ new assets.Asset(stack, 'BundledAsset', {
1616
`,
1717
],
1818
network: 'host',
19+
platform: 'linux/amd64',
1920
},
2021
});
2122
/// !hide

packages/aws-cdk-lib/core/lib/private/asset-staging.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class AssetBundlingBindMount extends AssetBundlingBase {
7171
...(this.options.volumes ?? []),
7272
],
7373
network: this.options.network,
74+
platform: this.options.platform,
7475
});
7576
}
7677
}
@@ -189,6 +190,7 @@ export class AssetBundlingVolumeCopy extends AssetBundlingBase {
189190
this.copyContainerName,
190191
...(this.options.volumesFrom ?? []),
191192
],
193+
platform: this.options.platform,
192194
});
193195

194196
this.copyOutputTo(this.options.bundleDir);

packages/aws-cdk-lib/core/test/private/asset-staging.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('bundling', () => {
2626
bundleDir: '/tmp/output',
2727
image: DockerImage.fromRegistry('public.ecr.aws/docker/library/alpine'),
2828
user: '1000',
29+
platform: 'linux/amd64',
2930
};
3031
const helper = new AssetBundlingVolumeCopy(options);
3132
helper.run();
@@ -78,6 +79,7 @@ describe('bundling', () => {
7879
// actual docker run
7980
expect(spawnSyncStub.calledWith(DOCKER_CMD, sinon.match.array.contains([
8081
'run', '--rm',
82+
'--platform', 'linux/amd64',
8183
'--volumes-from', helper.copyContainerName,
8284
'public.ecr.aws/docker/library/alpine',
8385
]), { encoding: 'utf-8', stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true);
@@ -100,6 +102,7 @@ describe('bundling', () => {
100102
image: DockerImage.fromRegistry('public.ecr.aws/docker/library/alpine'),
101103
user: '1000',
102104
network: 'host',
105+
platform: 'linux/amd64',
103106
};
104107
const helper = new AssetBundlingBindMount(options);
105108
helper.run();
@@ -108,6 +111,7 @@ describe('bundling', () => {
108111
expect(spawnSyncStub.calledWith(DOCKER_CMD, sinon.match.array.contains([
109112
'run', '--rm',
110113
'--network', 'host',
114+
'--platform', 'linux/amd64',
111115
'-v',
112116
'public.ecr.aws/docker/library/alpine',
113117
]), { encoding: 'utf-8', stdio: ['ignore', process.stderr, 'inherit'] })).toEqual(true);

0 commit comments

Comments
 (0)