Skip to content
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

fix(core): append file extension to s3 asset key in new style synthesizer #12765

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ export class DefaultStackSynthesizer extends StackSynthesizer {
assertBound(this.bucketName);
validateFileAssetSource(asset);

const objectKey = this.bucketPrefix + asset.sourceHash + (asset.packaging === FileAssetPackaging.ZIP_DIRECTORY ? '.zip' : '');
const extension = asset.fileName != undefined ? path.extname(asset.fileName) : '';
const objectKey = this.bucketPrefix + asset.sourceHash + (asset.packaging === FileAssetPackaging.ZIP_DIRECTORY ? '.zip' : extension);

// Add to manifest
this.files[asset.sourceHash] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ nodeunitShim({
destinations: {
'current_account-current_region': {
bucketName: 'cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}',
objectKey: templateHash,
objectKey: templateHash + '.json',
assumeRoleArn: 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}',
},
},
Expand Down Expand Up @@ -111,7 +111,7 @@ nodeunitShim({

// THEN - we have a fixed asset location with region placeholders
test.equals(evalCFN(location.bucketName), 'cdk-hnb659fds-assets-the_account-the_region');
test.equals(evalCFN(location.s3Url), 'https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef');
test.equals(evalCFN(location.s3Url), 'https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef.js');

// THEN - object key contains source hash somewhere
test.ok(location.objectKey.indexOf('abcdef') > -1);
Expand Down Expand Up @@ -208,7 +208,7 @@ nodeunitShim({

test.deepEqual(manifest.files?.['file-asset-hash']?.destinations?.['current_account-current_region'], {
bucketName: 'file-asset-bucket',
objectKey: 'file-asset-hash',
objectKey: 'file-asset-hash.js',
assumeRoleArn: 'file:role:arn',
assumeRoleExternalId: 'file-external-id',
});
Expand Down Expand Up @@ -256,7 +256,7 @@ nodeunitShim({
// THEN
test.deepEqual(manifest.files?.['file-asset-hash-with-prefix']?.destinations?.['current_account-current_region'], {
bucketName: 'file-asset-bucket',
objectKey: '000000000000/file-asset-hash-with-prefix',
objectKey: '000000000000/file-asset-hash-with-prefix.js',
assumeRoleArn: 'file:role:arn',
assumeRoleExternalId: 'file-external-id',
});
Expand Down