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_record: handle import for data #1942

Merged
merged 1 commit into from Sep 30, 2022

Conversation

jacobbednarz
Copy link
Member

Fixes the read method to pull from the remote API instead of the local configuration since on Import, the local configuration will be empty.

Fixes #1714

Fixes the read method to pull from the remote API instead of the local
configuration since on `Import`, the local configuration will be empty.

Fixes #1714
@jacobbednarz
Copy link
Member Author

acceptance tests all passing

TF_ACC=1 go test $(go list ./...) -v -run "^TestAccCloudflareRecord_" -count 1 -parallel 1 -timeout 120m -parallel 1
?       github.com/cloudflare/terraform-provider-cloudflare     [no test files]
=== RUN   TestAccCloudflareRecord_ImportBasic
--- PASS: TestAccCloudflareRecord_ImportBasic (11.86s)
=== RUN   TestAccCloudflareRecord_ImportSRV
--- PASS: TestAccCloudflareRecord_ImportSRV (12.70s)
=== RUN   TestAccCloudflareRecord_Basic
=== PAUSE TestAccCloudflareRecord_Basic
=== RUN   TestAccCloudflareRecord_CaseInsensitive
=== PAUSE TestAccCloudflareRecord_CaseInsensitive
=== RUN   TestAccCloudflareRecord_Apex
=== PAUSE TestAccCloudflareRecord_Apex
=== RUN   TestAccCloudflareRecord_LOC
=== PAUSE TestAccCloudflareRecord_LOC
=== RUN   TestAccCloudflareRecord_SRV
=== PAUSE TestAccCloudflareRecord_SRV
=== RUN   TestAccCloudflareRecord_CAA
=== PAUSE TestAccCloudflareRecord_CAA
=== RUN   TestAccCloudflareRecord_Proxied
=== PAUSE TestAccCloudflareRecord_Proxied
=== RUN   TestAccCloudflareRecord_Updated
=== PAUSE TestAccCloudflareRecord_Updated
=== RUN   TestAccCloudflareRecord_typeForceNewRecord
=== PAUSE TestAccCloudflareRecord_typeForceNewRecord
=== RUN   TestAccCloudflareRecord_hostnameForceNewRecord
=== PAUSE TestAccCloudflareRecord_hostnameForceNewRecord
=== RUN   TestAccCloudflareRecord_CreateAfterManualDestroy
=== PAUSE TestAccCloudflareRecord_CreateAfterManualDestroy
=== RUN   TestAccCloudflareRecord_TtlValidation
=== PAUSE TestAccCloudflareRecord_TtlValidation
=== RUN   TestAccCloudflareRecord_ExplicitProxiedFalse
=== PAUSE TestAccCloudflareRecord_ExplicitProxiedFalse
=== RUN   TestAccCloudflareRecord_MXWithPriorityZero
=== PAUSE TestAccCloudflareRecord_MXWithPriorityZero
=== RUN   TestAccCloudflareRecord_TtlValidationUpdate
=== PAUSE TestAccCloudflareRecord_TtlValidationUpdate
=== RUN   TestAccCloudflareRecord_HTTPS
=== PAUSE TestAccCloudflareRecord_HTTPS
=== CONT  TestAccCloudflareRecord_Basic
--- PASS: TestAccCloudflareRecord_Basic (8.89s)
=== CONT  TestAccCloudflareRecord_typeForceNewRecord
--- PASS: TestAccCloudflareRecord_typeForceNewRecord (16.07s)
=== CONT  TestAccCloudflareRecord_HTTPS
--- PASS: TestAccCloudflareRecord_HTTPS (8.90s)
=== CONT  TestAccCloudflareRecord_TtlValidationUpdate
--- PASS: TestAccCloudflareRecord_TtlValidationUpdate (11.73s)
=== CONT  TestAccCloudflareRecord_MXWithPriorityZero
--- PASS: TestAccCloudflareRecord_MXWithPriorityZero (8.40s)
=== CONT  TestAccCloudflareRecord_ExplicitProxiedFalse
--- PASS: TestAccCloudflareRecord_ExplicitProxiedFalse (21.22s)
=== CONT  TestAccCloudflareRecord_TtlValidation
--- PASS: TestAccCloudflareRecord_TtlValidation (3.44s)
=== CONT  TestAccCloudflareRecord_CreateAfterManualDestroy
--- PASS: TestAccCloudflareRecord_CreateAfterManualDestroy (18.55s)
=== CONT  TestAccCloudflareRecord_hostnameForceNewRecord
--- PASS: TestAccCloudflareRecord_hostnameForceNewRecord (21.38s)
=== CONT  TestAccCloudflareRecord_SRV
--- PASS: TestAccCloudflareRecord_SRV (8.79s)
=== CONT  TestAccCloudflareRecord_Updated
--- PASS: TestAccCloudflareRecord_Updated (15.63s)
=== CONT  TestAccCloudflareRecord_Proxied
--- PASS: TestAccCloudflareRecord_Proxied (8.55s)
=== CONT  TestAccCloudflareRecord_CAA
--- PASS: TestAccCloudflareRecord_CAA (15.15s)
=== CONT  TestAccCloudflareRecord_Apex
--- PASS: TestAccCloudflareRecord_Apex (8.72s)
=== CONT  TestAccCloudflareRecord_LOC
--- PASS: TestAccCloudflareRecord_LOC (8.97s)
=== CONT  TestAccCloudflareRecord_CaseInsensitive
--- PASS: TestAccCloudflareRecord_CaseInsensitive (12.11s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/internal/provider   221.751s

@@ -198,15 +198,14 @@ func resourceCloudflareRecordRead(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}

data, dataOk := d.GetOk("data")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the crux of the bug; it would look in d.Get for the value which on Import would never exist. this should have always pulled from the API anyway to ensure the remote was the source of truth, not the local files.

@github-actions
Copy link
Contributor

changelog detected ✅

@jacobbednarz jacobbednarz merged commit c076e03 into master Sep 30, 2022
@jacobbednarz jacobbednarz deleted the allow-importing-record-data branch September 30, 2022 06:39
@github-actions github-actions bot added this to the v3.25.0 milestone Sep 30, 2022
github-actions bot pushed a commit that referenced this pull request Sep 30, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

This functionality has been released in v3.25.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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

Successfully merging this pull request may close these issues.

import cloudflare_record of type SRV results in empty data-array in tfstate
1 participant