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

fix: mark verification key as computed when changing to or from partial zone type #4019

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

grounded042
Copy link
Contributor

@grounded042 grounded042 commented Sep 16, 2024

When changing a zone to or from type partial the cloudflare_zone.<ID>.verification_key will also change. However, the change is not reflected in the plan and thus any resources needing the value of verification_key won't pick up the change until the next apply. This is undesirable as you want to have the change reflected in one apply.

This PR changes it so that when type changes to or from partial Terraform knows that verification_key will be changed as well.

Before

Here's an example of before. As you can see when changing from full to partial it did not show that verification_key was changing.

Screenshot 2024-09-16 at 8 09 44 PM

On the next apply it picks up the change.

Screenshot 2024-09-16 at 8 09 58 PM

After

Here's what it looks like after: in the same apply that is changing from full to partial it shows that verification_key will change. Then, when the apply completes the value is there. No second apply needed.

Screenshot 2024-09-16 at 8 11 48 PM

Copy link
Contributor

github-actions bot commented Sep 16, 2024

changelog detected ✅

@grounded042 grounded042 changed the title feat: mark verification key as computed when changing to or from partial zone type fix: mark verification key as computed when changing to or from partial zone type Sep 17, 2024
@jacobbednarz
Copy link
Member

this has introduced a regression with the zone acceptance tests

TF_ACC=1 go test ./internal/sdkv2provider -v -run "^TestAccCloudflareZone_" -count 1 -timeout 120m -parallel 1
=== RUN   TestAccCloudflareZone_PreventZoneIdAndNameConflicts
=== PAUSE TestAccCloudflareZone_PreventZoneIdAndNameConflicts
=== RUN   TestAccCloudflareZone_NameLookup
=== PAUSE TestAccCloudflareZone_NameLookup
=== RUN   TestAccCloudflareZone_Basic
--- PASS: TestAccCloudflareZone_Basic (6.34s)
=== RUN   TestAccCloudflareZone_BasicWithJumpStartEnabled
--- PASS: TestAccCloudflareZone_BasicWithJumpStartEnabled (2.93s)
=== RUN   TestAccCloudflareZone_WithPlan
--- PASS: TestAccCloudflareZone_WithPlan (3.47s)
=== RUN   TestAccCloudflareZone_PartialSetup
    resource_cloudflare_zone_test.go:86: Step 1/1 error: After applying this test step, the non-refresh plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # cloudflare_zone.hwmxzqtkod will be updated in-place
          ~ resource "cloudflare_zone" "hwmxzqtkod" {
                id                  = "796fe6f98d347a6e594cc15617622483"
              ~ verification_key    = "179569341-1011955576" -> (known after apply)
                # (10 unchanged attributes hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccCloudflareZone_PartialSetup (6.13s)
=== RUN   TestAccCloudflareZone_FullSetup
--- PASS: TestAccCloudflareZone_FullSetup (3.47s)
=== RUN   TestAccCloudflareZone_WithEnterprisePlan
--- PASS: TestAccCloudflareZone_WithEnterprisePlan (7.45s)
=== RUN   TestAccCloudflareZone_WithEnterprisePlanVanityNameServers
--- PASS: TestAccCloudflareZone_WithEnterprisePlanVanityNameServers (8.05s)
=== RUN   TestAccCloudflareZone_Secondary
--- PASS: TestAccCloudflareZone_Secondary (9.66s)
=== RUN   TestAccCloudflareZone_SecondaryWithVanityNameServers
--- PASS: TestAccCloudflareZone_SecondaryWithVanityNameServers (7.55s)
=== RUN   TestAccCloudflareZone_SetType
    resource_cloudflare_zone_test.go:328: Step 2/2 error: After applying this test step, the non-refresh plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # cloudflare_zone.hxckgcnxjb will be updated in-place
          ~ resource "cloudflare_zone" "hxckgcnxjb" {
                id                  = "46b7b681132c8a2b0f769fe297ffe76c"
              ~ verification_key    = "379348556-1030387840" -> (known after apply)
                # (10 unchanged attributes hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccCloudflareZone_SetType (11.38s)
=== CONT  TestAccCloudflareZone_PreventZoneIdAndNameConflicts
--- PASS: TestAccCloudflareZone_PreventZoneIdAndNameConflicts (0.22s)
=== CONT  TestAccCloudflareZone_NameLookup
--- PASS: TestAccCloudflareZone_NameLookup (1.42s)
FAIL
FAIL	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider	68.596s
FAIL
make: *** [testacc] Error 1

Copy link
Contributor

Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label.
If this pull request was automatically closed and you feel this pull request should be reopened, we encourage creating a new pull request linking back to this one for added context. Thank you!

@grounded042
Copy link
Contributor Author

@jacobbednarz thanks for the info. I've updated the code and verified those acceptance tests now pass.

@jacobbednarz
Copy link
Member

nice one, thanks

TF_ACC=1 go test ./internal/sdkv2provider -v -run "^TestAccCloudflareZone_" -count 1 -timeout 120m -parallel 1
=== RUN   TestAccCloudflareZone_PreventZoneIdAndNameConflicts
=== PAUSE TestAccCloudflareZone_PreventZoneIdAndNameConflicts
=== RUN   TestAccCloudflareZone_NameLookup
=== PAUSE TestAccCloudflareZone_NameLookup
=== RUN   TestAccCloudflareZone_Basic
--- PASS: TestAccCloudflareZone_Basic (3.97s)
=== RUN   TestAccCloudflareZone_BasicWithJumpStartEnabled
--- PASS: TestAccCloudflareZone_BasicWithJumpStartEnabled (3.33s)
=== RUN   TestAccCloudflareZone_WithPlan
--- PASS: TestAccCloudflareZone_WithPlan (3.65s)
=== RUN   TestAccCloudflareZone_PartialSetup
--- PASS: TestAccCloudflareZone_PartialSetup (3.40s)
=== RUN   TestAccCloudflareZone_FullSetup
--- PASS: TestAccCloudflareZone_FullSetup (3.66s)
=== RUN   TestAccCloudflareZone_WithEnterprisePlan
--- PASS: TestAccCloudflareZone_WithEnterprisePlan (7.05s)
=== RUN   TestAccCloudflareZone_WithEnterprisePlanVanityNameServers
--- PASS: TestAccCloudflareZone_WithEnterprisePlanVanityNameServers (11.27s)
=== RUN   TestAccCloudflareZone_Secondary
--- PASS: TestAccCloudflareZone_Secondary (6.14s)
=== RUN   TestAccCloudflareZone_SecondaryWithVanityNameServers
--- PASS: TestAccCloudflareZone_SecondaryWithVanityNameServers (6.83s)
=== RUN   TestAccCloudflareZone_SetType
--- PASS: TestAccCloudflareZone_SetType (11.81s)
=== CONT  TestAccCloudflareZone_PreventZoneIdAndNameConflicts
--- PASS: TestAccCloudflareZone_PreventZoneIdAndNameConflicts (0.19s)
=== CONT  TestAccCloudflareZone_NameLookup
--- PASS: TestAccCloudflareZone_NameLookup (1.52s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider	63.979s

@jacobbednarz jacobbednarz merged commit 5cda265 into cloudflare:master Oct 15, 2024
6 checks passed
@github-actions github-actions bot added this to the v4.44.0 milestone Oct 15, 2024
Copy link
Contributor

This functionality has been released in v4.44.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!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants