NickH48226
NickH48226

Reputation: 147

AWS CDK Grab Nested Stack for Pipeline Test

I am writing unit tests in AWS-CDK for a pipeline that has multiple stages / stacks that are being deployed cross account. Within each stage, there is a stack that gets generated that I need to get the cloud formation of that template. I have this in a snapshot test now to verify the template but this only contains the parent / pipeline stack with the stage definition, not the actual stage stack. In the pipeline stack, I see the below for the stage which i need to get the template / template configuration from the stack to synth it. Is there a way to synth this into a template to get the information?

},
    "StackName": "mystagestack-deploy-mgmt-stack",
    "TemplateConfiguration": "Synth_Output::assembly-IntegrationRepoStack/mystagestack-deploy-mgmt-stack.template.json.config.json",
    "TemplatePath": "Synth_Output::assembly-IntegrationRepoStack/mystagestack-deploy-mgmt-stack.template.json",
},

Thanks Nick

Upvotes: 2

Views: 1599

Answers (1)

Nate Norris
Nate Norris

Reputation: 996

You might be looking for Template.fromStack(myStack) -- this returns a synthesized Template object that you can then make detailed assertions about.

https://docs.aws.amazon.com/cdk/v2/guide/testing.html#testing_fine_grained

Upvotes: -1

Related Questions