Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Automatic Resource Creation (Beta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post shows up in Cloudflare changelog — how do I know which product this is about?

What can I the person reading this now do?

description: When you deploy a Worker that binds to a Cloudflare resource, Wrangler will automatically detect and create any resources that do not exist on your account.
products:
- workers
date: 2025-02-14 00:00:00 UTC
---

You can now automatically create Cloudflare resources as part of your deployment! You no longer need to manually create any resources that do not yet exist on your account prior to deploying. Wrangler will automatically detect any required [KV](/kv), [D1](/d1), or [R2](/r2) resources and create them on your behalf.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better than title

Don't need ! part


For more details, check out our [documentation](/workers/wrangler/automatic-resource-creation) on how to get started with automatic resource creation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sold it needs to be a named thing like "automatic resource creation"

Also doesn't match what is in the CLI flag that says "provision" - should call it same thing


```bash
$ wrangler deploy --x-provision
⛅️ wrangler 3.109.0
--------------------

Total Upload: 0.29 KiB / gzip: 0.22 KiB

The following bindings need to be provisioned:
- KV Namespaces:
- MY_KV
- D1 Databases:
- MY_D1
- R2 Buckets:
- MY_R2

...

🎉 All resources provisioned, continuing with deployment...

Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: ...
- D1 Databases:
- MY_D1: ...
- R2 Buckets:
- MY_R2: ...
Uploaded my-worker
Deployed my-worker triggers
https://my-worker.workers.dev
Current Version ID: ...
```

Resource provisiong is currently a beta feature. If you run into issues or would like to leave feedback for the team to help us improve, please send us a message in our [Cloudflare Developers Discord](https://discord.cloudflare.com/) in the [Wrangler channel](https://discord.com/channels/595317990191398933/799437470004412476).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just say it's beta — same stuff here about reporting stuff applies equality beta and non beta?

Beta already in title

97 changes: 97 additions & 0 deletions src/content/docs/workers/wrangler/automatic-resource-creation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
pcx_content_type: concept
title: Automatic Resource Creation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment before about naming

description: When you deploy a Worker that binds to a Cloudflare resource, Wrangler will automatically detect and create any resources that do not exist on your account.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page really makes sense too-level in wrangler docs?

sidebar:
badge:
text: Beta
---

import { PackageManagers, WranglerConfig } from "~/components";

You can now automatically provision Cloudflare resources as part of your deployment. You no longer need to manually create any resources that do not yet exist on your account prior to deploying.

With resource provisioning, if your Wrangler configuration file includes a [KV namespace](/kv/), [D1 database](/d1/), or [R2 bucket](/r2/) that does not yet exist, Wrangler will create these resources upon deployment. This is done by adding the experimental `-–x-provision` flag to your commands.

## Wrangler Configuration
You can set up your Wrangler configuration file like the following:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think missing something here — the instead of

(Running commands first)


<WranglerConfig>
```json
{
"kv_namespaces": [
{
"binding": "MY_KV"
}
],
"r2_buckets": [
{
"binding": "MY_R2"
}
],
"d1_databases": [
{
"binding": "MY_D1"
}
]
}
```
</WranglerConfig>

When using the experimental `-–x-provision` flag, the `id` field for KV and D1 and the `bucket_name` for R2 are optional in your wrangler configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't explain how it works though and how the resource is mapped to a specific KV namespace? If I have binding FOO declared in wrangler.toml for a KV namespace, and I login to the dash, how do I figure out what is what?


## Developing locally and deploying
When developing locally, you can interact with local versions of any KV, D1, R2 resources configured in your Wrangler configuration file by running:

<PackageManagers
type="exec"
pkg="wrangler"
args={"dev –-x-provision"}
/>

When you're ready to deploy, run:

<PackageManagers
type="exec"
pkg="wrangler"
args={"deploy –-x-provision"}
/>

Upon deploy Wrangler will automatically create the resources that do not yet exist on your accound and bind them to your Worker.

```bash
$ wrangler deploy --x-provision
⛅️ wrangler 3.109.0
--------------------

Total Upload: 0.29 KiB / gzip: 0.22 KiB

The following bindings need to be provisioned:
- KV Namespaces:
- MY_KV
- D1 Databases:
- MY_D1
- R2 Buckets:
- MY_R2

...

🎉 All resources provisioned, continuing with deployment...

Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: ...
- D1 Databases:
- MY_D1: ...
- R2 Buckets:
- MY_R2: ...
Uploaded my-worker
Deployed my-worker triggers
https://my-worker.workers.dev
Current Version ID: ...
```

The newly created resource will be named with the format `<worker-name>-<binding-name>` by default.

## Feedback
Resource provisiong is currently a beta feature. If you run into issues or would like to leave feedback for the team to help us improve, please send us a message in our [Cloudflare Developers Discord](https://discord.cloudflare.com/) in the [Wrangler channel](https://discord.com/channels/595317990191398933/799437470004412476).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Resource provisiong is currently a beta feature. If you run into issues or would like to leave feedback for the team to help us improve, please send us a message in our [Cloudflare Developers Discord](https://discord.cloudflare.com/) in the [Wrangler channel](https://discord.com/channels/595317990191398933/799437470004412476).
Resource provisiong is currently in beta. Drop us a note in the [Cloudflare Developers Discord](https://discord.cloudflare.com/) in the [Wrangler channel](https://discord.com/channels/595317990191398933/799437470004412476) and tell us what you think

Loading