Skip to content

Commit 47320f6

Browse files
committed
docs: add new workers improvements changelog
1 parent f4b587c commit 47320f6

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: Improvements to the Workers Terraform resources and SDKs
3+
description: Multiple improvements to the Workers Terraform resources and SDKs including fixes for plan diffs, Durable Objects migrations, file uploads, and new Python Workers support.
4+
products:
5+
- workers
6+
date: 2025-07-28
7+
---
8+
9+
The recent [Cloudflare Terraform Provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/workers_script) and SDK releases (such as [cloudflare-typescript](https://github.com/cloudflare/cloudflare-typescript)) bring significant improvements to the Workers developer experience. These updates focus on reliability, performance, and adding Python Workers support.
10+
11+
## Terraform Improvements
12+
13+
### Fixed Unwarranted Plan Diffs
14+
15+
Resolved several issues with the `cloudflare_workers_script` resource that resulted in unwarranted plan diffs, including:
16+
17+
- Using Durable Objects migrations
18+
- Using some bindings such as `secret_text`
19+
- Using smart placement
20+
- When the API returned array attribute results in different order
21+
22+
A resource should never show a plan diff if there isn't an actual change. This fix reduces unnecessary noise in your Terraform plan and is available in Cloudflare Terraform Provider 5.8.0.
23+
24+
### Fixed Durable Objects Migration Issues
25+
26+
Resolved an issue in `cloudflare_workers_script` when using Durable Objects migrations which always failed on the second terraform apply. Configurations like this would work on the first apply, but fail on subsequent ones:
27+
28+
```tf
29+
resource "cloudflare_workers_script" "my_worker" {
30+
account_id = "123456789"
31+
script_name = "my_worker"
32+
# ...
33+
bindings = [
34+
{
35+
name = "MY_DO"
36+
type = "durable_object_namespace"
37+
class_name = "MyDOClass"
38+
}
39+
]
40+
41+
migrations = {
42+
new_tag = "v1"
43+
new_sqlite_classes = ["MyDOClass"]
44+
}
45+
}
46+
```
47+
48+
This is now fixed and available in Cloudflare Terraform Provider 5.8.0.
49+
50+
### Improved File Management
51+
52+
You can now specify `content_file = "worker.js"` and `content_sha256 = filesha256("worker.js")` instead of `content = file("worker.js")`. This prevents the Workers script content from being stored in the state file which greatly reduces plan diff size and noise. If your workflow synced plans remotely, this should now happen much faster since there is less data to sync. This is available in Cloudflare Terraform Provider 5.7.0.
53+
54+
### Assets Headers and Redirects Support
55+
56+
Fixed the `cloudflare_workers_script` resource to properly support headers and redirects for Assets:
57+
58+
```tf
59+
resource "cloudflare_workers_script" "my_worker" {
60+
account_id = "123456789"
61+
script_name = "my_worker"
62+
content_file = "worker.js"
63+
content_sha256 = filesha256("worker.js")
64+
assets = {
65+
config = {
66+
headers = file("headers")
67+
redirects = file("redirects")
68+
}
69+
# Completion jwt from:
70+
# https://developers.cloudflare.com/api/resources/workers/subresources/assets/subresources/upload/
71+
jwt = "jwt"
72+
}
73+
}
74+
```
75+
76+
Available in Cloudflare Terraform Provider 5.8.0.
77+
78+
### Python Workers Support
79+
80+
Added support for uploading [Python Workers](/workers/languages/python/) (beta) in Terraform. You can now deploy Python Workers with:
81+
82+
```tf
83+
resource "cloudflare_workers_script" "my_worker" {
84+
account_id = "123456789"
85+
script_name = "my_worker"
86+
content_file = "worker.py"
87+
content_sha256 = filesha256("worker.py")
88+
}
89+
```
90+
91+
Available in Cloudflare Terraform Provider 5.8.0.
92+
93+
## SDK Enhancements
94+
95+
### Improved File Upload API
96+
97+
Fixed an issue where Workers script versions in the SDK did not allow uploading files. This now works and also has an improved files upload interface:
98+
99+
```js
100+
const scriptContent = `
101+
export default {
102+
async fetch(request, env, ctx) {
103+
return new Response('Hello World!', { status: 200 });
104+
}
105+
};
106+
`;
107+
108+
client.workers.scripts.versions.create('my-worker', {
109+
account_id: '123456789',
110+
metadata: {
111+
main_module: 'my-script',
112+
},
113+
files: [
114+
await toFile(
115+
Buffer.from(scriptContent),
116+
'my-script',
117+
{
118+
type: "application/javascript+module",
119+
}
120+
)
121+
]
122+
});
123+
```
124+
125+
Available in cloudflare-typescript 4.6.0. A similar change will be available in cloudflare-python 4.4.0.
126+
127+
### Fixed updating KV values
128+
129+
Previously when create a KV value like this:
130+
131+
```js
132+
await cf.kv.namespaces.values.update("my-kv-namespace", "key1", {
133+
account_id: "123456789",
134+
metadata: "my metadata",
135+
value: JSON.stringify({
136+
hello: "world"
137+
})
138+
});
139+
```
140+
141+
And recalled it in your Worker like this:
142+
```ts
143+
const value = await c.env.KV.get<{hello: string}>("key1", "json");
144+
```
145+
146+
You'd get back this: `{metadata:'my metadata', value:"{'hello':'world'}"}` instead of the correct value of `{hello: 'world'}`
147+
148+
This is fixed in cloudflare-typescript 4.5.0 and will be fixed in cloudflare-python 4.4.0.

0 commit comments

Comments
 (0)