Skip to content

Commit

Permalink
fix(ecr-assets): cannot build ARM images using modern stack synthesis (
Browse files Browse the repository at this point in the history
…#20563)

#20439 added support for the --platform option for docker build but the platform prop was not properly passed through when using the new DefaultStackSynthesizer. 

----

### 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

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] 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*
  • Loading branch information
joeflateau authored Jun 1, 2022
1 parent e44c2c4 commit 9a23575
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class AssetManifestBuilder {
dockerBuildTarget: asset.dockerBuildTarget,
dockerFile: asset.dockerFile,
networkMode: asset.networkMode,
platform: asset.platform,
},
destinations: {
[this.manifestEnvName(stack)]: {
Expand Down

0 comments on commit 9a23575

Please sign in to comment.