-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Nevi/wrangler-resource-provisioning #19832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
537312f
resource-provisioning-beta docs
nevikashah 0c0bed2
add resource provisioning beta
nevikashah e26a906
Use shared components
penalosa d9dc918
resource-creation
nevikashah 29cf526
resource-creation + changelog
nevikashah c87f267
update image name
nevikashah 8866af6
image -> text
penalosa 54480d8
updates 2/14
nevikashah 6f6b124
Update src/content/docs/workers/wrangler/automatic-resource-provision…
ToriLindsay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/content/changelog/workers/2025-02-14-automatic-resource-provisioning-beta.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| title: Automatically provision Cloudflare resources when deploying a Worker with Wrangler (Beta) | ||
| 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 when deploying a Worker with Wrangler. 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. | ||
|
|
||
| ```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: ... | ||
| ``` | ||
| For more details, check out our [documentation](/workers/wrangler/automatic-resource-provisioning) on how to get started. | ||
95 changes: 95 additions & 0 deletions
95
src/content/docs/workers/wrangler/automatic-resource-provisioning.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| pcx_content_type: concept | ||
| title: Automatically provision Cloudflare resources when deploying a Worker with Wrangler (Beta) | ||
| 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. | ||
| 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 run separate commands to create 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 detect and 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: | ||
|
|
||
| <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. | ||
|
|
||
| ## 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 account and bind them to your Worker. Each newly created resource will be named with the format `<worker-name>-<binding-name>` by default. | ||
|
|
||
| ```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: ... | ||
| ``` | ||
|
|
||
| ## Feedback | ||
| Resource provisioning 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.