Skip to content

Commit 3c70074

Browse files
markjmiller1000hz
andauthored
docs: add new workers improvements changelog (#24025)
docs: add new workers improvements changelog Co-authored-by: Brendan Irvine-Broque <[email protected]> Cina Saffary <[email protected]>
1 parent ee87b3b commit 3c70074

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: Terraform provider improvements — Python Workers support, smaller plan diffs, and API SDK fixes
3+
description: Multiple improvements to the Workers Terraform resources and SDKs including fixes for plan diffs, file uploads, and Python Workers support.
4+
products:
5+
- workers
6+
date: 2025-08-14
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](/workers/languages/python/) 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+
21+
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.
22+
23+
### Improved File Management
24+
25+
You can now specify `content_file` and `content_sha256` instead of `content`. 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.
26+
27+
```tf
28+
resource "cloudflare_workers_script" "my_worker" {
29+
account_id = "123456789"
30+
script_name = "my_worker"
31+
main_module = "worker.mjs"
32+
content_file = "worker.mjs"
33+
content_sha256 = filesha256("worker.mjs")
34+
}
35+
```
36+
37+
### Assets Headers and Redirects Support
38+
39+
Fixed the `cloudflare_workers_script` resource to properly support headers and redirects for Assets:
40+
41+
```tf
42+
resource "cloudflare_workers_script" "my_worker" {
43+
account_id = "123456789"
44+
script_name = "my_worker"
45+
main_module = "worker.mjs"
46+
content_file = "worker.mjs"
47+
content_sha256 = filesha256("worker.mjs")
48+
assets = {
49+
config = {
50+
headers = file("_headers")
51+
redirects = file("_redirects")
52+
}
53+
# Completion jwt from:
54+
# https://developers.cloudflare.com/api/resources/workers/subresources/assets/subresources/upload/
55+
jwt = "jwt"
56+
}
57+
}
58+
```
59+
60+
Available in Cloudflare Terraform Provider 5.8.0.
61+
62+
### Python Workers Support
63+
64+
Added support for uploading [Python Workers](/workers/languages/python/) (beta) in Terraform. You can now deploy Python Workers with:
65+
66+
```tf
67+
resource "cloudflare_workers_script" "my_worker" {
68+
account_id = "123456789"
69+
script_name = "my_worker"
70+
content_file = "worker.py"
71+
content_sha256 = filesha256("worker.py")
72+
content_type = "text/x-python"
73+
}
74+
```
75+
76+
Available in Cloudflare Terraform Provider 5.8.0.
77+
78+
## SDK Enhancements
79+
80+
### Improved File Upload API
81+
82+
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:
83+
84+
```js
85+
const scriptContent = `
86+
export default {
87+
async fetch(request, env, ctx) {
88+
return new Response('Hello World!', { status: 200 });
89+
}
90+
};
91+
`;
92+
93+
client.workers.scripts.versions.create('my-worker', {
94+
account_id: '123456789',
95+
metadata: {
96+
main_module: 'my-worker.mjs',
97+
},
98+
files: [
99+
await toFile(
100+
Buffer.from(scriptContent),
101+
'my-worker.mjs',
102+
{
103+
type: "application/javascript+module",
104+
}
105+
)
106+
]
107+
});
108+
```
109+
110+
Will be available in cloudflare-typescript 4.6.0. A similar change will be available in cloudflare-python 4.4.0.
111+
112+
### Fixed updating KV values
113+
114+
Previously when creating a KV value like this:
115+
116+
```js
117+
await cf.kv.namespaces.values.update("my-kv-namespace", "key1", {
118+
account_id: "123456789",
119+
metadata: "my metadata",
120+
value: JSON.stringify({
121+
hello: "world"
122+
})
123+
});
124+
```
125+
126+
...and recalling it in your Worker like this:
127+
```ts
128+
const value = await c.env.KV.get<{hello: string}>("key1", "json");
129+
```
130+
131+
You'd get back this: `{metadata:'my metadata', value:"{'hello':'world'}"}` instead of the correct value of `{hello: 'world'}`
132+
133+
This is fixed in cloudflare-typescript 4.5.0 and will be fixed in cloudflare-python 4.4.0.

0 commit comments

Comments
 (0)