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

pop_pools, region_pools, and country_pools do not remove when last block is removed #2659

Closed
2 tasks done
troymjones opened this issue Aug 4, 2023 · 5 comments · Fixed by #2673
Closed
2 tasks done
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Milestone

Comments

@troymjones
Copy link
Contributor

troymjones commented Aug 4, 2023

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.5.3
on darwin_arm64

  • provider registry.terraform.io/cloudflare/cloudflare v4.11.0

Affected resource(s)

cloudflare_load_balancer

Terraform configuration files

# Resource update
resource "cloudflare_load_balancer" "pop-cf-test" {
  name        = "my-test-lb.cf.my-test-domain.com"
  description = "my-test-lb"
  default_pool_ids = [
    cloudflare_load_balancer_pool.failover_pool_geo.id,
  ]
  fallback_pool_id = cloudflare_load_balancer_pool.fallback_pool_geo.id
  enabled          = true
  proxied          = true
  steering_policy  = "geo"
  zone_id          = data.cloudflare_zone.my_test_domain.id
}

# Resource created
resource "cloudflare_load_balancer" "pop-cf-test" {
  name        = "my-test-lb.cf.my-test-domain.com"
  description = "my-test-lb"
  default_pool_ids = [
    cloudflare_load_balancer_pool.failover_pool_geo.id,
  ]
  fallback_pool_id = cloudflare_load_balancer_pool.fallback_pool_geo.id
  enabled          = true
  proxied          = true
  steering_policy  = "geo"
  zone_id          = data.cloudflare_zone.my_test_domain.id

  pop_pools {
    pool_ids = [
      cloudflare_load_balancer_pool.pool.id,
      cloudflare_load_balancer_pool.failover_pool_geo.id,
    ]
    pop = "FSD"
  }

  region_pools {
    pool_ids = [
      cloudflare_load_balancer_pool.pool.id,
      cloudflare_load_balancer_pool.failover_pool_geo.id,
    ]
    region = "EEU"
  }
}

Link to debug output

Relevant output: https://gist.github.com/troymjones/815f8f633abf9296c949dc5dc254803b
Full output: https://gist.github.com/troymjones/00ba9c87e5c1f9c260473d32ca6e1f18

Panic output

No response

Expected output

Terraform will perform the following actions:

  # cloudflare_load_balancer.pop-cf-test will be updated in-place
  ~ resource "cloudflare_load_balancer" "pop-cf-test" {
        id               = "<zone_id>"
        name             = "my-test-lb.cf.my-test-domain.com"
        # (11 unchanged attributes hidden)

      - pop_pools {
          - pool_ids = [
              - "<pool_id>",
              - "<pool_id>",
            ] -> null
          - pop      = "FSD" -> null
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Actual output

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

Steps to reproduce

  1. Create and apply load balancer resource with pop_pools, region_pools and/or country_pools blocks
  2. Remove all of the remaining pop_pools, region_pools and/or country_pools blocks
  3. Run terraform plan and/or terraform apply
  4. No changes are shown in the plan or apply

Additional factoids

This seems to be an issue with the fact the key does not exist and therefore the blank/null value is never set. See code here: https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/sdkv2provider/resource_cloudflare_load_balancer.go#L184-L190

Datadog has a similar provider with assertions under datadog_synthetics_test resource. By setting it as an empty object before checking for the key, it gets set to a blank value if the key does not exist. See code here: https://github.com/DataDog/terraform-provider-datadog/blob/master/datadog/resource_datadog_synthetics_test_.go#L1458

References

No response

@troymjones troymjones added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

@github-actions github-actions bot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 4, 2023
troymjones pushed a commit to troymjones/terraform-provider-cloudflare that referenced this issue Aug 4, 2023
troymjones pushed a commit to troymjones/terraform-provider-cloudflare that referenced this issue Aug 4, 2023
troymjones pushed a commit to troymjones/terraform-provider-cloudflare that referenced this issue Aug 4, 2023
@jacobbednarz
Copy link
Member

can you please provide the entirety of the debug output? i'm not seeing where the issue is here.

@troymjones
Copy link
Contributor Author

Here's the full debug output, but there's a lot in there that isn't relevant. https://gist.github.com/troymjones/00ba9c87e5c1f9c260473d32ca6e1f18

The original gist above only shows the relevant portion.

Did you see the example given as well as the expected output?

To summarize - when a load balancer has pop_pools set, they correctly apply. Then on an update, when all the pop_pools blocks are removed, the terraform does not show any changes when it should in fact remove the pop_pools and show an update to the load balancer. Instead it shows no changes and the apply makes no updates. This is the same situation with country_pools and region_pools.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

This functionality has been released in v4.12.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 Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
2 participants