terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

Test existence of Providers with properties

Open coen-hyde opened this issue 3 years ago • 6 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I have a stack that generates a lot of providers. I would like to write tests to ensure they exist and were created with specific properties. This doesn't appear possible atm. It would be good to have something similar to toHaveResourceWithProperties but for providers. Please correct me if this is indeed possible.

coen-hyde avatar Mar 30 '22 23:03 coen-hyde

To clarify: You want to test the generated provider bindings itself, or the instantiated provider in a stack? I'm assuming you're using Typescript?

skorfmann avatar Mar 31 '22 07:03 skorfmann

I want to test the instantiated providers in a stack. I ended up parsing the rendered Terraform json and validating it that way. But feels like there should be a prettier way.

coen-hyde avatar Mar 31 '22 20:03 coen-hyde

@coen-hyde @ansgarm I am new to community. Can you just throw some light on this issue ? I am interested in working on it.

aayushharwani-aidash avatar May 07 '22 11:05 aayushharwani-aidash

@aayushharwani-aidash This would be adding additional testing capabilities. Take a look here for more information on testing.

Technically this involves adding another function similar to this one, but for looking at the provider and maybe terraform.required_providers sections of the synthesized output: https://github.com/hashicorp/terraform-cdk/blob/a3338f49abc001dafe35833511392f45553b1a61/packages/cdktf/lib/testing/matchers.ts#L151

We would also want to update the testing docs to include the new functions.

jsteinich avatar May 07 '22 16:05 jsteinich

I understood issue. I am interested to work on it but not getting where to start. Will anyone like to help me ? @jsteinich @ansgarm @skorfmann

aayushharwani-aidash avatar May 14 '22 16:05 aayushharwani-aidash

I understood issue. I am interested to work on it but not getting where to start. Will anyone like to help me ? @jsteinich @ansgarm @skorfmann

Are you in the cdk dev slack? You could ask specific questions in the terraform-cdk channel.

jsteinich avatar May 17 '22 01:05 jsteinich

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Dec 16 '22 01:12 github-actions[bot]