aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.65k stars 3.91k forks source link

(assertions): add `hasParameters()` and `findParameters()` API #16720

Closed kaizencc closed 2 years ago

kaizencc commented 3 years ago

There should be a way to access the Parameters of the template natively with the assertions library.

Use Case

https://github.com/aws/aws-cdk/blob/7fbf092c613f5618575b9b1a10b9e06fa36abad3/packages/%40aws-cdk/aws-autoscaling/test/scheduled-action.test.ts#L61

There are quite a few lines of code in the above example so I did not quote it all. But the idea is that if you want to assert on any parameters along with the properties, you can only use Template.fromStack(stack).templateMatches() which then requires you to provide the entire template. This is excess code if the user does not need to assert that the entire template is a 1-1 match.

Proposed Solution

APIs similar to what is available for hasMapping(), hasResource(), and hasOutput(). Should also have findParameters() as well.

Other

Workaround is:

expect(Template.fromStack(stack).toJSON().Parameters).toEqual({});

This is a :rocket: Feature Request

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.