From 744d7dab69d79e8b12b7c80039530a04e8a90de3 Mon Sep 17 00:00:00 2001 From: Joe Flateau Date: Tue, 31 May 2022 22:20:47 -0400 Subject: [PATCH] ensure docker build platform is passed along to DefaultStackSynthesizer --- .../aws-ecr-assets/test/image-asset.test.ts | 16 ++++++++++++++++ .../_asset-manifest-builder.ts | 1 + 2 files changed, 17 insertions(+) diff --git a/packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts b/packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts index 4fe6299ab9c87..89a5aeb3d0309 100644 --- a/packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts +++ b/packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts @@ -170,6 +170,22 @@ describe('image asset', () => { expect(assetMetadata && (assetMetadata.data as cxschema.ContainerImageAssetMetadataEntry).platform).toEqual('linux/arm64'); }); + testFutureBehavior('with platform: default synth edition', flags, App, (app) => { + // GIVEN + const stack = new Stack(app, 'Stack', { synthesizer: new DefaultStackSynthesizer() }); + // WHEN + const asset = new DockerImageAsset(stack, 'Image', { + directory: path.join(__dirname, 'demo-image'), + platform: Platform.LINUX_ARM64, + }); + + // THEN + const asm = app.synth(); + const stackAssets = JSON.parse(fs.readFileSync(path.join(asm.directory, 'Stack.assets.json'), { encoding: 'utf-8' })); + const dockerImageAsset = stackAssets.dockerImages[asset.assetHash]; + expect(dockerImageAsset.source.platform).toEqual('linux/arm64'); + }); + testFutureBehavior('asset.repository.grantPull can be used to grant a principal permissions to use the image', flags, App, (app) => { // GIVEN const stack = new Stack(app); diff --git a/packages/@aws-cdk/core/lib/stack-synthesizers/_asset-manifest-builder.ts b/packages/@aws-cdk/core/lib/stack-synthesizers/_asset-manifest-builder.ts index b1e121399cf4a..3d0d833245b8d 100644 --- a/packages/@aws-cdk/core/lib/stack-synthesizers/_asset-manifest-builder.ts +++ b/packages/@aws-cdk/core/lib/stack-synthesizers/_asset-manifest-builder.ts @@ -93,6 +93,7 @@ export class AssetManifestBuilder { dockerBuildTarget: asset.dockerBuildTarget, dockerFile: asset.dockerFile, networkMode: asset.networkMode, + platform: asset.platform, }, destinations: { [this.manifestEnvName(stack)]: {