terraform-provider-cloudflare
terraform-provider-cloudflare copied to clipboard
Errors cloudflare_worker_route on deploying cloudflare worker, still deployed
Confirmation
- [X] My issue isn't already found on the issue tracker.
- [X] I have replicated my issue using the latest version of the provider and it is still present.
Terraform and Cloudflare provider version
Terraform v1.2.8 on darwin_amd64
provider "registry.terraform.io/cloudflare/cloudflare" { version = "3.23.0"
Affected resource(s)
cloudflare_worker_route
Terraform configuration files
resource "cloudflare_worker_route" "dev_route_fr" {
zone_id = "1b7dd3eaf3a7c18aa98611412c431529"
pattern = "https://mydomain.fr/*"
script_name = var.worker_name
}
Link to debug output
Too sensitive
Panic output
No response
Expected output
╷
│ Warning: Argument is deprecated
│
│ with provider["registry.terraform.io/cloudflare/cloudflare"],
│ on main.tf line 10, in provider "cloudflare":
│ 10: account_id = "51a5bbd4faef206ff8316320780300bd"
│
│ Use resource specific `account_id` attributes instead.
│
│ (and 2 more similar warnings elsewhere)
╵
Actual output
╷
│ Warning: Argument is deprecated
│
│ with provider["registry.terraform.io/cloudflare/cloudflare"],
│ on main.tf line 10, in provider "cloudflare":
│ 10: account_id = "51a5bbd4faef206ff8316320780300bd"
│
│ Use resource specific `account_id` attributes instead.
│
│ (and 2 more similar warnings elsewhere)
╵
╷
│ Error: error creating worker route: workers.api.error.duplicate_route (10020)
│
│ with module.dev_route.cloudflare_worker_route.dev_route_int,
│ on ../../modules/routes/dev/main.tf line 7, in resource "cloudflare_worker_route" "dev_route_int":
│ 7: resource "cloudflare_worker_route" "dev_route_int" {
│
╵
Steps to reproduce
- terraform plan
- terraform apply -input=false -auto-approve
Throws errors but still deploys the worker. Do not overwrite the routes
Additional factoids
POST /client/v4/zones/1b7dd3eaf3a7c18aa98611412c431529/workers/routes HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform/1.2.8 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/dev
Content-Length: 87
Authorization: [redacted]
Content-Type: application/json
Accept-Encoding: gzip
{
"pattern": "https://mydomain.fr/*",
"enabled": false,
"script": "worker-dev"
}
---[ RESPONSE ]--------------------------------------
HTTP/2.0 409 Conflict
Cf-Cache-Status: DYNAMIC
Cf-Ray: 746e9871bb52998c-CDG
Content-Type: application/json; charset=UTF-8
Date: Wed, 07 Sep 2022 10:00:08 GMT
Server: cloudflare
Set-Cookie: [redacted]
Set-Cookie: [redacted]
Vary: Accept-Encoding
X-Envoy-Upstream-Service-Time: 1391
{
"result": null,
"success": false,
"errors": [
{
"code": 10020,
"message": "workers.api.error.duplicate_route"
}
],
"messages": []
}
References
No response
without the debug output, there isn't really a whole heap I can do here.
reading from the error message, the route is already assigned to another script so you can't assign it to this one. the only thing I can recommend here is to remove the first route association and then assign it to this script.
It's not assigned to another script. That the thing it worker like a charm before @jacobbednarz
It still deploys the worker. But the message should be an warning not a error
the error is coming from the API (not Terraform) so somewhere internally, the service is getting a conflict. if it's not assigned, you can open a support ticket to find out what is happening.
closing this one out as it is the service API returning an error that the route is already assigned and cannot be overwritten with a POST (the update in place uses a PUT). i'm also limited in what diagnosis help i can provide here given you cannot provide any debug logs.
if you have any more information that points to an issue in the provider or can provide debug logs, we can revisit as a bug report.