-
Notifications
You must be signed in to change notification settings - Fork 626
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
Use zone_id if available and fallback on domain for record state migration #566
Use zone_id if available and fallback on domain for record state migration #566
Conversation
I'm a little on the fence with this one as this issue (as you mentioned) is brought upon because your state is marked as v0 when it's actually not. The v0 schema does indeed have In any case, we also need to update the integration tests for this change for it to be considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jacobbednarz, thanks for the feedback.
This change actually avoids the ZoneIDByName()
call in the context of state migration when zone_id
is defined so I guess this is fine.
I've added an integration testcase for this specific case, feel free to let me know if this is was what you expected or not.
@@ -147,7 +174,7 @@ func TestCloudflareRecordMigrateState(t *testing.T) { | |||
} | |||
|
|||
if is.ID != tc.Expected { | |||
t.Fatalf("bad sg rule id: %s\n\n expected: %s", is.ID, tc.Expected) | |||
t.Fatalf("bad record id: %s\n\n expected: %s", is.ID, tc.Expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great pickup! thanks!
What I was more getting at is that everything inside of that block isn't needed as I'm happy to ship as is for now and we can revisit if we decide it's worth it. |
Oh, I didn't realize that. Good point then to remove the usage of |
Co-authored-by: Justin Holmes <jholmes@cloudflare.com>
This PR works around an issue when the schema version of a
cloudflare_record
resource stored in the state is 0 while the attributes are actually those of schema version 1:Note: I ended up with such state when importing a Cloudflare zone's records using terraformer.
In this situation, the state migration function invokes the Cloudflare API with an empty query string which errors:
I believe this should also resolve issues like https://github.com/terraform-providers/terraform-provider-cloudflare/issues/484