-
Notifications
You must be signed in to change notification settings - Fork 768
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 v1.13.5
Cloudflare Terraform provider:
registry.terraform.io/cloudflare/cloudflare v5.13.0
Operating system:
macOS 15.0 (Sonoma)
Authentication:
API token with:
- Zone: Zone:Read, DNS:Edit
- Account: Workers Scripts:Edit, Workers Builds Configuration:Edit
Affected resource(s)
cloudflare_workers_custom_domain
cloudflare_worker
Terraform configuration files
locals {
webshop_worker_name = "webshop-frontend-${var.env_id}"
webshop_hostname = "shop.${var.env_id}.${var.root_dev_domain}"
}
locals {
cloudflare_account_id = var.cloudflare_account_id
}
data "cloudflare_zone" "root" {
filter = {
name = var.root_dev_domain
}
}
resource "cloudflare_worker" "webshop_frontend" {
account_id = local.cloudflare_account_id
name = local.webshop_worker_name
subdomain = {
enabled = false
previews_enabled = false
}
}
resource "cloudflare_workers_custom_domain" "webshop_frontend" {
account_id = local.cloudflare_account_id
zone_id = data.cloudflare_zone.root.zone_id
environment = "production"
hostname = local.webshop_hostname
service = cloudflare_worker.webshop_frontend.name
}Link to debug output
https://gist.github.com/ffrants/1ce45543d4707ff2f8b422e3934ff032
Panic output
N/A – no panic, only HTTP 500 error from Cloudflare API.
Expected output
The cloudflare_workers_custom_domain.webshop_frontend resource is created successfully and the Worker custom domain is configured via the /accounts/<ACCOUNT_ID>/workers/domains API without errors.
Actual output
The Worker service itself is created successfully by cloudflare_worker.webshop_frontend, but cloudflare_workers_custom_domain.webshop_frontend fails with a 500 error from the Cloudflare API.
Terraform apply output:
cloudflare_workers_custom_domain.webshop_frontend: Creating...
Error: failed to make http request
with cloudflare_workers_custom_domain.webshop_frontend,
on webshop_frontend_worker.tf line 20, in resource "cloudflare_workers_custom_domain" "webshop_frontend":
20: resource "cloudflare_workers_custom_domain" "webshop_frontend" {
PUT "https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/workers/domains": 500 Internal Server Error
{
"result": null,
"success": false,
"errors": [
{
"code": 10013,
"message": "An unknown error has occurred. If this error persists, please file a report in workers-sdk (https://github.com/cloudflare/workers-sdk/issues) or reach out to your account team."
}
],
"messages": []
}
Steps to reproduce
- Configure the Cloudflare provider with an API token that has:
- Zone: Zone:Read, DNS:Edit
- Account: Workers Scripts:Edit, Workers Builds Configuration:Edit
- Use the minimal Terraform configuration from the "Terraform configuration files" section with:
- env_id = "dev"
- pixion_id_dev_domain = "example.com"
- cloudflare_account_id = "<ACCOUNT_ID>"
- Run:
terraform apply -var-file=env/dev.auto.tfvars - Observe that:
cloudflare_worker.webshop_frontendis created successfully.cloudflare_workers_custom_domain.webshop_frontendfails with a 500 error (code 10013) onPUT /accounts/<ACCOUNT_ID>/workers/domains.
Additional factoids
I originally reported this to the Workers SDK team here:
cloudflare/workers-sdk#11412
They confirmed this should be handled by the Terraform provider team and asked me to open an issue here.
This behaviour is 100% reproducible for this account/zone/hostname combination. Retrying the same configuration always returns the same 500 / 10013 error.
References
Related Workers SDK issue:
cloudflare/workers-sdk#11412