zone: Swap to using subscription API for setting plans#362
Merged
patryk merged 2 commits intocloudflare:masterfrom Oct 16, 2019
Merged
Conversation
While debugging an issue in the Terraform provider[1] I've come across a broken endpoint whereby attempting to set a zone's rate plan silently fails using this method. After a chat with some Cloudflare Engineers, we're going to move to using the Subscription API instead which has this functionality and is the intended approach to updating a zone's rate plan. [1]: terraform-providers/terraform-provider-cloudflare#488
Contributor
Author
|
@martijngonlag would you mind casting your eyes over this and make sure this is what the intended use is? |
patryk
approved these changes
Oct 16, 2019
patryk
pushed a commit
to cloudflare/terraform-provider-cloudflare
that referenced
this pull request
Oct 17, 2019
* resource/cloudflare_zone: account for pending zone setups During the creation of a zone, the plan name is always "free" despite the desired end result of a paid plan while it is in a "pending" state. In most API scenarios this doesn't really matter as the plan value shifts on it's own behind the scenes. However as Terraform keeps track of the input vs the remote state, this becomes problematic as it sees the difference in the desired state. To account for this, we need to check if the state is pending and then dig into the `plan_pending` object for the real plan in order to do the comparison. Fixes #488 * No need to use `d.Get`, we have an object already * Defer setting the plan type until `Read` At the point of creation, we set the rate plan however we don't need to worry about the status check until _after_ we've set it. This gets re-performed in the `Read` method after the resource is created. * Refactor `setRatePlan` for new usage In cloudflare/cloudflare-go#362 we are addressing an underlying issue with an existing method used to set the zone rate plan. To move to this, we update our usage of the library which as a side benefit, gets rid of some of the extra work we were doing in this method. * bump cloudflare-go to v0.10.6 * Swap to backoff and retry for rate plan propagation * Handle creates and updates For the subscription API, creates use a POST and updates use PUT. We also can't just POST everything so we need to determine when we are updating and use a similar (yet slightly different) HTTP verb.
Michael9127
pushed a commit
to Michael9127/cloudflare-go
that referenced
this pull request
Oct 28, 2019
* zone: Swap to using subscription API for setting plans While debugging an issue in the Terraform provider[1] I've come across a broken endpoint whereby attempting to set a zone's rate plan silently fails using this method. After a chat with some Cloudflare Engineers, we're going to move to using the Subscription API instead which has this functionality and is the intended approach to updating a zone's rate plan. [1]: terraform-providers/terraform-provider-cloudflare#488 * include a way to update zone rate plans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While debugging an issue in the Terraform provider I've come across
a broken endpoint whereby attempting to set a zone's rate plan
silently fails using this method. After a chat with some Cloudflare
Engineers, we're going to move to using the Subscription API instead
which has this functionality and is the intended approach to updating
a zone's rate plan.