franckverrot / terraform-provider-stripe

A Terraform Provider for Stripe
https://registry.terraform.io/providers/franckverrot/stripe/latest
Mozilla Public License 2.0
242 stars 51 forks source link

Allow for $0 plan #35

Closed trea closed 3 years ago

trea commented 4 years ago

Hello!

I was trying to create a $0 plan and ran into the issue described in #32. As I didn't see any movement on that, I took a stab at it myself.

Since one or the other of amount and amount decimal is allowed, I apply the value of decimal amount if it's greater than zero and fallback to the amount otherwise. If it's not set or explicitly set to zero, that should get the desired result.

Don't hesitate to let me know if I can do anything to improve it!

Thanks, Trea

franckverrot commented 3 years ago

Just getting to this today, thanks for sending this, I'll review.

trea commented 3 years ago

Sure thing! I'm around today, so if I can help in any way, don't hesitate to let me know!

franckverrot commented 3 years ago

So, it seems like the API won't let me create a free plan, but I can totally set it in the UI, and also modify the state to assume no changes need to be done 🤔

Do you mind sharing (here or in the PR in the example file) what configuration you used to make this pass? Thanks!

franckverrot commented 3 years ago

Heads-up that this is probably coming from my setup... Terraform 13's internal still confuses me a bit :-)

trea commented 3 years ago

This is my first time doing anything with Terraform plugins aside from consuming them so I hope you are able to figure that out! 😂 I'll get an example put in the example file for you here shortly!

trea commented 3 years ago

Oh! I had to use a different process to actually use the new plugin locally, the one in the Makefile didn't work for me 🤷‍♂️

I altered the makefile install step to:

.PHONY=install
install: compile
    mkdir -p ./.terraform/plugins/registry.terraform.io/franckverrot/stripe/1.7.1/darwin_amd64
    cp ./terraform-provider-stripe ./.terraform/plugins/registry.terraform.io/franckverrot/stripe/1.7.1/darwin_amd64/terraform-provider-stripe_v1.7.1

Then I changed the version constraint in main.tf to 1.7.1 and ran terraform init again and it worked.

trea commented 3 years ago

I added an example of a product with a free plan by the way. Hope this helps! Let me know if you need anything else!

franckverrot commented 3 years ago

Thanks for the hints, I figured it out by so many trials and errors... 😭

It's functional, so it's merged now. I'll release soon, I want to do a few other minor changes before. Thanks again for your time!

trea commented 3 years ago

Fantastic, and you're welcome! Thank you for the plugin!