All skills
openai avatar

/cloudflare-deploy

@bf9e226 official
by openaiopenai/skills28k stars
1,891

Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.

Use this Skill: https://skilld.dev/gh/openai/skills/cloudflare-deploy

This session only. Nothing lands on disk.

referencespulumigotchas.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Troubleshooting & Best Practices

Common Errors

"No bundler/build step" - Pulumi uploads raw code

Problem: Worker fails with "Cannot use import statement outside a module"
Cause: Pulumi doesn't bundle Worker code - uploads exactly what you provide
Solution: Build Worker BEFORE Pulumi deploy

// WRONG: Pulumi won't bundle this
const worker = new cloudflare.WorkerScript("worker", {
    content: fs.readFileSync("./src/index.ts", "utf8"), // Raw TS file
});

// RIGHT: Build first, then deploy
import * as command from "@pulumi/command";
const build = new command.local.Command("build", {
    create: "npm run build",
    dir: "./worker",
});
const worker = new cloudflare.WorkerScript("worker", {
    content: build.stdout.apply(() => fs.readFileSync("./worker/dist/index.js", "utf8")),
}, {dependsOn: [build]});

"wrangler.toml not consumed" - Config drift

Problem: Local wrangler dev works, Pulumi deploy fails
Cause: Pulumi ignores wrangler.toml - must duplicate config
Solution: Generate wrangler.toml from Pulumi or keep synced manually

// Pattern: Export Pulumi config to wrangler.toml
const workerConfig = {
    name: "my-worker",
    compatibilityDate: "2025-01-01",
    compatibilityFlags: ["nodejs_compat"],
};

new command.local.Command("generate-wrangler", {
    create: pulumi.interpolate`cat > wrangler.toml <<EOF
name = "${workerConfig.name}"
compatibility_date = "${workerConfig.compatibilityDate}"
compatibility_flags = ${JSON.stringify(workerConfig.compatibilityFlags)}
EOF`,
});

"False no-changes detection" - Content SHA unchanged

Problem: Worker code updated, Pulumi says "no changes"
Cause: Content hash identical (whitespace/comment-only change)
Solution: Add build timestamp or version to force update

const version = Date.now().toString();
const worker = new cloudflare.WorkerScript("worker", {
    content: code,
    plainTextBindings: [{name: "VERSION", text: version}], // Forces new deployment
});

"D1 migrations don't run on pulumi up"

Problem: Database schema not applied after D1 database created
Cause: Pulumi creates database but doesn't run migrations
Solution: Use Command resource with dependsOn

const db = new cloudflare.D1Database("db", {accountId, name: "mydb"});

// Run migrations after DB created
const migration = new command.local.Command("migrate", {
    create: pulumi.interpolate`wrangler d1 execute ${db.name} --file ./schema.sql`,
}, {dependsOn: [db]});

// Worker depends on migrations
const worker = new cloudflare.WorkerScript("worker", {
    d1DatabaseBindings: [{name: "DB", databaseId: db.id}],
}, {dependsOn: [migration]});

"Missing required property 'accountId'"

Problem: Error: Missing required property 'accountId'
Cause: Account ID not provided in resource configuration
Solution: Add to stack config

# Pulumi.<stack>.yaml
config:
  cloudflare:accountId: "abc123..."

"Binding name mismatch"

Problem: Worker fails with "env.MY_KV is undefined"
Cause: Binding name in Pulumi != name in Worker code
Solution: Match exactly (case-sensitive)

// Pulumi
kvNamespaceBindings: [{name: "MY_KV", namespaceId: kv.id}]

// Worker code
export default { async fetch(request, env) { await env.MY_KV.get("key"); }}

"API token permissions insufficient"

Problem: Error: authentication error (10000)
Cause: Token lacks required permissions
Solution: Grant token permissions: Account.Workers Scripts:Edit, Account.Account Settings:Read

"Resource not found after import"

Problem: Imported resource shows as changed on next pulumi up
Cause: State mismatch between actual resource and Pulumi config
Solution: Check property names/types match exactly

pulumi import cloudflare:index/workerScript:WorkerScript my-worker <account_id>/<worker_name>
pulumi preview # If shows changes, adjust Pulumi code to match actual resource

"v6.x Worker versioning confusion"

Problem: Worker deployed but not receiving traffic
Cause: v6.x requires Worker + WorkerVersion + WorkersDeployment (3 resources)
Solution: Use WorkerScript (auto-versioning) OR full versioning pattern

// SIMPLE: WorkerScript auto-versions (default behavior)
const worker = new cloudflare.WorkerScript("worker", {
    accountId, name: "my-worker", content: code,
});

// ADVANCED: Manual versioning for gradual rollouts (v6.x)
const worker = new cloudflare.Worker("worker", {accountId, name: "my-worker"});
const version = new cloudflare.WorkerVersion("v1", {
    accountId, workerId: worker.id, content: code, compatibilityDate: "2025-01-01",
});
const deployment = new cloudflare.WorkersDeployment("prod", {
    accountId, workerId: worker.id, versionId: version.id,
});

Best Practices

  1. Always set compatibilityDate - Locks Worker behavior, prevents breaking changes
  2. Build before deploy - Pulumi doesn't bundle; use Command resource or CI build step
  3. Match binding names - Case-sensitive, must match between Pulumi and Worker code
  4. Use dependsOn for migrations - Ensure D1 migrations run before Worker deploys
  5. Version Worker content - Add VERSION binding to force redeployment on content changes
  6. Store secrets in stack config - Use pulumi config set --secret for API keys

Limits

Resource Limit Notes
Worker script size 10 MB Includes all dependencies, after compression
Worker CPU time 50ms (free), 30s (paid) Per request
KV keys per namespace Unlimited 1000 ops/sec write, 100k ops/sec read
R2 storage Unlimited Class A ops: 1M/mo free, Class B: 10M/mo free
D1 databases 50,000 per account Free: 10 per account, 5 GB each
Queues 10,000 per account Free: 1M ops/day
Pages projects 500 per account Free: 100 projects
API requests Varies by plan ~1200 req/5min on free

Resources


See: README.md, configuration.md, api.md, patterns.md

Source: SKILL.md on GitHub

2 warnings17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides comprehensive guidance for deploying and managing infrastructure on the Cloudflare platform. It includes extensive educational material on secure development practices, such as preventing SQL injection and managing secrets effectively. No malicious patterns or security risks were identified.

  • Socket17d

    2 alerts: gptAnomaly

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    310/310 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at bf9e226. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 8 months ago

README badge

README badge for openai/skills/cloudflare-deploy

Deploys applications and infrastructure to Cloudflare's platform, including Workers, Pages, D1, R2, Durable Objects, KV, and other services. Use decision trees to route to the right Cloudflare product based on compute, storage, AI, networking, security, or media needs.

Generated from the current SKILL.md.

Does this skill cover all Cloudflare products?
The skill is a consolidated index covering compute, storage, AI, networking, security, media, and developer tools on Cloudflare. It uses decision trees to route you to the right product reference, then loads detailed guidance for that product.
What authentication is required before deploying?
Run `npx wrangler whoami` to check if authenticated. For local deployment, use `wrangler login` (one-time OAuth). For CI/CD, set the `CLOUDFLARE_API_TOKEN` environment variable.
What should I do if deployment fails due to network issues?
Rerun the deploy with `sandbox_permissions=require_escalated` to grant elevated network access, which is required for outbound requests to Cloudflare during deployment.
How long does a Cloudflare deployment typically take?
Deployments may take several minutes. Use appropriate timeout values in your configuration or CI/CD environment.

Generated from the current SKILL.md. These answers refresh after source changes.