Skip to content

targeted placement isn't working for cloudflare_workers_script on v5.17.0 and up #6936

@pesochek

Description

@pesochek

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 -v
Terraform v1.14.7
on windows_386

  • provider registry.terraform.io/cloudflare/cloudflare v5.19.0-beta.2
  • provider registry.terraform.io/hashicorp/null v3.2.4

Affected resource(s)

  • cloudflare_workers_script

Terraform configuration files

resource "cloudflare_workers_script" "http_router" {
  account_id         = "some-account-id"
  compatibility_date = "2026-01-20"
  content            = "console.log('hello world')"
  script_name        = "http-router"

  placement = {
    mode = "targeted"
    target = [{
      region = "aws:us-east-2"
    }]
  }
}

Link to debug output

https://gist.github.com/pesochek/0ebcfdf680d81079977b26e30c3ddd06

Panic output

No response

Expected output

Expected is to get the Worker placed in the specific region as it can be done via the Cloudflare dashboard:

Image

Actual output

$ terraform plan
â•·
│ Error: Invalid Configuration for Read-Only Attribute
│
│   with cloudflare_workers_script.http_router,
│   on worker.tf line 1, in resource "cloudflare_workers_script" "http_router":
│    1: resource "cloudflare_workers_script" "http_router" {
│
│ Cannot set value for this attribute as the provider has marked it as
│ read-only. Remove the configuration line setting the value.
│
│ Refer to the provider documentation or contact the provider developers for
│ additional information about configurable and read-only attributes that are
│ supported.
╵

Steps to reproduce

  1. Create minimal plan with just the worker resource
  2. Be sure to place it into a specific region of your cloud provider (AWS us-east-2 in the example)
  3. Run "terraform plan" and observe the error

Additional factoids

I know that only the placement.mode can be set according to the resource documentation, and other attributes are just read-only. But if we check the changelog for v5.17.0, it actually says that targeted placement should be now supported:

workers_script: add support for targeted placement mode with placement.target array for specifying placement targets (region, hostname, host)

I tried this plan on v5.17.0 and on the latest beta 5.19.0-beta.2, it fails with the same error in both scenarios.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions