Skip to content

Commit

Permalink
fix: assert matches more than the template on multiple CDK copies (a…
Browse files Browse the repository at this point in the history
…ws#14544)

The `assert` library sometimes fails to get the template out of a
`CloudFormationStackArtifact` if there are multiple copies of the CDK in
the dependency tree.

Fix by replacing an `instanceof` with a duck-type check.

Fixes aws#14468.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored and hollanddd committed Aug 26, 2021
1 parent 3e50d47 commit d63c276
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/@aws-cdk/assert-internal/lib/synth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SynthUtils {
*/
public static toCloudFormation(stack: core.Stack, options: core.SynthesisOptions = { }): any {
const synth = this._synthesizeWithNested(stack, options);
if (synth instanceof cxapi.CloudFormationStackArtifact) {
if (isStackArtifact(synth)) {
return synth.template;
} else {
return synth;
Expand Down Expand Up @@ -85,3 +85,7 @@ export interface SubsetOptions {
*/
resourceTypes?: string[];
}

function isStackArtifact(x: object): x is cxapi.CloudFormationStackArtifact {
return 'template' in x;
}

0 comments on commit d63c276

Please sign in to comment.