cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
754 stars 576 forks source link

Multiple `cloudflare_list_item` cannot be a substring of an existing entry on the list #3506

Closed patrick-vares-stash closed 1 month ago

patrick-vares-stash commented 1 month ago

Confirmation

Terraform and Cloudflare provider version

Terraform v1.9.2
on darwin_arm64
+ provider registry.terraform.io/cloudflare/cloudflare v4.38.0

Affected resource(s)

cloudflare_list_item

Terraform configuration files

resource "cloudflare_list" "test_bug" {
  account_id  = var.account_id
  name        = "bug_list"
  description = "list for testing a bug"
  kind        = "hostname"
}

resource "cloudflare_list_item" "item_1" {
  account_id = var.account_id
  list_id    = cloudflare_list.test_bug.id
  comment    = "item substring"
  hostname {
    url_hostname = "bug.test"
  }
}

resource "cloudflare_list_item" "item_2" {
  account_id = var.account_id
  list_id    = cloudflare_list.test_bug.id
  comment    = "item superstring"
  hostname {
    url_hostname = "differing-bug.test"
  }
}

Link to debug output

https://gist.github.com/patrick-vares-stash/5910e2100e4ded69566145bffbe522db

Panic output

No response

Expected output

Successful create of 3 resources:

Actual output

Successful create of 2 resources:

Failed create of 1 resource:

2024-07-25T14:50:11.964-0400 [ERROR] vertex "cloudflare_list_item.item_1" error: failed to create list item: <unknown>

Error: failed to create list item: <unknown>

  with cloudflare_list_item.item_1,
  on test_list.tf line 8, in resource "cloudflare_list_item" "item_1":
   8: resource "cloudflare_list_item" "item_1" {

failed to match exactly one list item

Steps to reproduce

  1. Create a cloudflare_list with kind = "hostname"
  2. Create a cloudflare_list_item with hostname.url_hostname = "some.string"
  3. Create a cloudflare_list_item with hostname.url_hostname = "longer-some.string"
  4. Run terraform apply and observe that Terraform is unable to successfully complete the apply
  5. Note that all cloudflare_list_items are actually present within the CloudFlare console

Additional factoids

A screenshot of the created list within the CloudFlare console after applying the failing terraform above

image

References

No response

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 1 month ago

we've patched this for other types in #3368 and #3335. if you want to send over a PR for the fix here, i'll take a look.

patrick-vares-stash commented 1 month ago

Sure: https://github.com/cloudflare/terraform-provider-cloudflare/pull/3515