Skip to content

Commit

Permalink
fix(integ-runner): asset hashes of nested stack templates are not ign…
Browse files Browse the repository at this point in the history
…ored
  • Loading branch information
mrgrain committed Nov 9, 2022
1 parent 4bdb18e commit 0f54a68
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,23 @@ export class AssemblyManifestReader {
const fileName = (artifact.properties as AssetManifestProperties).file;
const assetManifest = AssetManifest.fromFile(path.join(this.directory, fileName));
assetManifest.entries.forEach(entry => {
if (entry.type === 'file') {
const source = (entry as FileManifestEntry).source;
if (source.path && source.path.startsWith('asset.')) {
switch (entry.type) {
case 'file':
assets.push(entry as FileManifestEntry);
}
} else if (entry.type === 'docker-image') {
const source = (entry as DockerImageManifestEntry).source;
if (source.directory && source.directory.startsWith('asset.')) {
return;
case 'docker-image':
assets.push(entry as DockerImageManifestEntry);
}
return;
default:
return;
}
});

return assets;
}

/**
* Clean the manifest of any unneccesary data. Currently that includes
* Clean the manifest of any unnecessary data. Currently that includes
* the metadata trace information since this includes trace information like
* file system locations and file lines that will change depending on what machine the test is run on
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ describe('IntegTest runSnapshotTests', () => {
reason: DiagnosticReason.SNAPSHOT_FAILED,
testName: integTest.testName,
message: expect.stringContaining('S3Key'),
}),
expect.objectContaining({
reason: DiagnosticReason.SNAPSHOT_FAILED,
testName: integTest.testName,
message: expect.stringContaining('TemplateURL'),
})]));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"DIFFERENT_NESTED_STACK_HASH": {
"source": {
"path": "SomeNestedStackResourceA7AEBA6B.nested.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "DIFFERENT_NESTED_STACK_HASH.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@
"S3Key": "be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92825.zip"
},
"Role": {
"Fn::GetAtt": [
"MyFunction1ServiceRole9852B06B",
"Arn"
]
"Fn::GetAtt": ["MyFunction1ServiceRole9852B06B", "Arn"]
},
"Handler": "index.handler",
"Runtime": "nodejs14.x"
},
"DependsOn": [
"MyFunction1ServiceRole9852B06B"
]
"DependsOn": ["MyFunction1ServiceRole9852B06B"]
},
"SomeNestedStackResourceA7AEBA6B": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.unknown-region.amazonaws.com/cdk-hnb659fds-assets-unknown-account-unknown-region/DIFFERENT_NESTED_STACK_HASH.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
"objectKey": "cb05f22f001734dbadeb4f07d875c6ab8180f703346a8d66fca572a0e94c54a9.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
},
"6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9": {
"source": {
"path": "SomeNestedStackResourceA7AEBA6B.nested.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"DependsOn": [
"MyFunction1ServiceRole9852B06B"
]
},
"SomeNestedStackResourceA7AEBA6B": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.unknown-region.amazonaws.com/cdk-hnb659fds-assets-unknown-account-unknown-region/6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"DIFFERENT_NESTED_STACK_HASH": {
"source": {
"path": "SomeNestedStackResourceA7AEBA6B.nested.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "DIFFERENT_NESTED_STACK_HASH.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"DependsOn": [
"MyFunction1ServiceRole9852B06B"
]
},
"SomeNestedStackResourceA7AEBA6B": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.unknown-region.amazonaws.com/cdk-hnb659fds-assets-unknown-account-unknown-region/DIFFERENT_NESTED_STACK_HASH.json"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9": {
"source": {
"path": "SomeNestedStackResourceA7AEBA6B.nested.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"DependsOn": [
"MyFunction1ServiceRole9852B06B"
]
},
"SomeNestedStackResourceA7AEBA6B": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.unknown-region.amazonaws.com/cdk-hnb659fds-assets-unknown-account-unknown-region/6f980d09d47a00a7d5001feeb3994d1909bc5294e309d69bd4fbc815622f6fa9.json"
}
}
}
}

0 comments on commit 0f54a68

Please sign in to comment.