Skip to content

(cloudflare_workers_script) Durable Object migrations not applied #5898

@1000hz

Description

@1000hz

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

5.8.0 – 5.8.2

Affected resource(s)

  • cloudflare_workers_script

Terraform configuration files

resource "cloudflare_workers_script" "worker" {
  account_id = var.account_id
  script_name = "tf-durable-object-migrations"
  content = <<-EOT
    import {DurableObject} from "cloudflare:workers"
    export class MyDurableObject extends DurableObject {}
    export default { fetch() {return new Response()} } 
  EOT
  main_module = "worker.js"
  bindings = [{
    name = "MY_DO"
    class_name = "MyDurableObject"
    type = "durable_object_namespace"
  }]
  migrations = {
    new_tag = "v1"
    new_sqlite_classes = ["MyDurableObject"]
  }
}

Link to debug output

Panic output

No response

Expected output

Worker script is successfully created.

Actual output

│ Error: failed to make http request
│
│ PUT "https://api.cloudflare.com/client/v4/accounts/redacted/workers/scripts/tf-durable-object-migrations": 400 Bad Request {
│   "result": null,
│   "success": false,
│   "errors": [
│     {
│       "code": 10061,
│       "message": "Cannot create binding for class 'MyDurableObject' because it is not currently configured to implement Durable Objects. Ensure a --new-class migration has been applied to it."
│     }
│   ],
│   "messages": []
│ }
│ 

Steps to reproduce

Try to apply the above Terraform config.

Additional factoids

To address #5701, we marked cloudflare_workers_script.migrations as WriteOnly: true in the provider.

However, Terraform omits WriteOnly attributes from both state and plans. Since the resource implementation sources its data from the plan rather than directly from config, migrations are being omitted from Create/Update requests.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions