Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/cloudflare_zone: No need to translate the ID to Name back to ID #668

Merged
merged 3 commits into from
Apr 29, 2020

Conversation

jacobbednarz
Copy link
Member

@jacobbednarz jacobbednarz commented Apr 26, 2020

Within the Update we set the rate plan which requires the
subscription ID mapped value. We already have the legacy ID so we
don't need to pass it through the planIDForName method which we
previously.

I suspect this was a copy-paste issue from the Read method as we
were also setting the plan value to the plan name which would
haven't have been accepted in the schema anyway. In
addition to this, I've also updated the call to setRatePlan to take
into account whether or not the old plan was "free" which requires
a POST (not PUT) HTTP request to create a new subscription despite
the resource already existing.

Closes #667

@ghost ghost added the size/XS label Apr 26, 2020
Within the `Update` we set the rate plan which requires the
subscription ID mapped value[1]. We already have the legacy ID[2] so we
don't need to pass it through the `planIDForName` method which we
previously.

I suspect this was a copy-paste issue from the `Read` method as we
were also setting the `plan` value to the plan name which would
haven't have been accepted in the schema anyway. This commit trims
all of that out and just passes the ID as it should have always done.

[1]: https://github.com/terraform-providers/terraform-provider-cloudflare/blob/master/cloudflare/resource_cloudflare_zone.go#L35-L40
[2]: https://github.com/terraform-providers/terraform-provider-cloudflare/blob/master/cloudflare/resource_cloudflare_zone.go#L18-L23
[3]: https://github.com/terraform-providers/terraform-provider-cloudflare/blob/master/cloudflare/resource_cloudflare_zone.go#L81
Turns out if you need to upgrade from a free plan to an enterprise
plan, you need to create the subscription (using POST) not modify an
existing one (PUT).

Updates the call the `setRatePlan` to work out which HTTP verb to use
based on the incoming plan ID change.
This isn't a huge deal but seeing how I'm touching this code, I can make
it more efficient by only making the `setRatePlan` calls if we have
changed the plan. Otherwise, pass over it.
@jacobbednarz jacobbednarz merged commit c36c1dd into cloudflare:master Apr 29, 2020
@jacobbednarz jacobbednarz deleted the dont-treat-an-id-as-name branch April 30, 2020 03:09
boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this pull request Feb 28, 2022
…cache-purging

add purge prefixes capability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't change plan type for zone already active on Cloudflare
2 participants