-
Notifications
You must be signed in to change notification settings - Fork 734
Closed
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.Categorizes issue or PR as related to version 5 of the provider.
Description
Confirmation
- This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
- I have searched the issue tracker and my issue isn't already found.
- I have replicated my issue using the latest version of the provider and it is still present.
Terraform and Cloudflare provider version
Terraform Configuration
terraform {
required_version = ">= 1.10.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "= 5.3.0"
}
}
}
Bug
The resource cloudflare_workers_route has a broken behavior when dealing with route_id.
- If you do not specify route_id, Terraform fails at plan/apply stage with:
- If you do specify route_id manually, Terraform plan fails because:
- Cloudflare API returns 409 conflict that the route already exists (even though the ID was passed explicitly)
- Terraform then marks the resource as “not found” and removes it from state
This results in an infinite loop of trying to recreate a route that already exists, which cannot be imported or retained in state reliably.
missing required route_id parameter
╷
│ Error: failed to make http request
│
│ with cloudflare_workers_route.cf_route_prometheus_v2,
│ on cf-auth-g2.tf line 26, in resource "cloudflare_workers_route" "cf_route_prometheus_v2":
│ 26: resource "cloudflare_workers_route" "cf_route_prometheus_v2" {
│
│ missing required route_id parameter
╵
exit status 1
Expected Behavior
- If route_id is meant to be computed from Cloudflare API, it should not be required.
- If route_id is required during updates, then it must be fetchable and usable — either by import or automatic reading.
- Manual assignment of route_id should be supported or at least ignored cleanly if unnecessary.
Workaround
Manually delete from state and Cloudflare, re-create resource every time.
Affected resource(s)
- cloudflare_workers_route
Terraform configuration files
resource "cloudflare_workers_route" "cf_route_prometheus_v2" {
zone_id = "..."
pattern = "prometheus.example.com/*"
script = "example-worker"
# Any combination here triggers route_id-related issues
}
Link to debug output
no-way-its-prod
Panic output
No response
Expected output
│ Error: failed to make http request
│
│ with cloudflare_workers_route.cf_auth_route_vm_g2,
│ on cf-auth.tf line 28, in resource "cloudflare_workers_route" "cf_auth_route_vm_g2":
│ 28: resource "cloudflare_workers_route" "cf_auth_route_vm_g2" {
│
│ POST
│ "https://api.cloudflare.com/client/v4/zones/54a75d9682397657fc1a0987b06f5c13/workers/routes":
│ 409 Conflict {
│ "result": null,
│ "success": false,
│ "errors": [
│ {
│ "code": 10020,
│ "message": "A route with the same pattern already exists. Either delete the existing route or try a different pattern."
│ }
│ ],
│ "messages": []
│ }
│
╵
Actual output
│ Error: failed to make http request
│
│ with cloudflare_workers_route.cf_auth_route_vm_g2,
│ on cf-auth.tf line 28, in resource "cloudflare_workers_route" "cf_auth_route_vm_g2":
│ 28: resource "cloudflare_workers_route" "cf_auth_route_vm_g2" {
│
│ POST
│ "https://api.cloudflare.com/client/v4/zones/54a75d9682397657fc1a0987b06f5c13/workers/routes":
│ 409 Conflict {
│ "result": null,
│ "success": false,
│ "errors": [
│ {
│ "code": 10020,
│ "message": "A route with the same pattern already exists. Either delete the existing route or try a different pattern."
│ }
│ ],
│ "messages": []
│ }
│
╵
Steps to reproduce
Steps to Reproduce
Then:
- terraform apply — success
- terraform plan — fails with missing required route_id parameter
- Add route_id = "..." manually
- Apply → fails with 409 conflict: route already exists
- Terraform now wants to delete from state or recreate indefinitely
resource "cloudflare_workers_route" "cf_route_prometheus_v2" {
zone_id = "..."
pattern = "prometheus.example.com/*"
script = "example-worker"
# Any combination here triggers route_id-related issues
}
Additional factoids
No response
References
No response
rwojsznis, edencaldas, saidjamesphilip, nuclearpengy, johnhunterkennedy and 10 more
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.Categorizes issue or PR as related to version 5 of the provider.