Skip to content

Commit 67eac4b

Browse files
committed
fixup
1 parent 2621497 commit 67eac4b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/content/docs/workers/configuration/environment-variables.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export default {
4949

5050
### Configuring different environments in Wrangler
5151

52-
You can set up [environments in Wrangler](/workers/wrangler/environments), and specify different values for your environment variables in each environment.
53-
`vars` is a non-inheritable key. [Non-inheritable keys](/workers/wrangler/configuration/#non-inheritable-keys) are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
52+
[Environments in Wrangler](/workers/wrangler/environments) let you specify different configurations for the same worker, including different values for `vars` in each environment.
53+
As `vars` is a [non-inheritable key](/workers/wrangler/configuration/#non-inheritable-keys), they are not inherited by environments and must be specified for each environment.
5454

5555
The example below sets up two environments, `staging` and `production`, with different values for `API_HOST` and `API_ACCOUNT_ID`.
5656

@@ -62,17 +62,15 @@ name = "my-worker-dev"
6262
[env.staging.vars]
6363
API_HOST = "staging.example.com"
6464
API_ACCOUNT_ID = "staging_example_user"
65-
SERVICE_X_DATA = { URL = "service-x-api.dev.example", MY_ID = 123 }
6665

6766
[env.production.vars]
6867
API_HOST = "production.example.com"
6968
API_ACCOUNT_ID = "production_example_user"
70-
SERVICE_X_DATA = { URL = "service-x-api.prod.example", MY_ID = 456 }
7169
```
7270

7371
</WranglerConfig>
7472

75-
To run Wrangler commands in specific environments, you can pass in the `--env` or `-e` flag. For example, you can develop the Worker in the `dev` environment by running `npx wrangler dev -e=staging`, and deploy it with `npx wrangler deploy -e=production`.
73+
To run Wrangler commands in specific environments, you can pass in the `--env` or `-e` flag. For example, you can develop the Worker in an environment called `staging` by running `npx wrangler dev --env=staging`, and deploy it with `npx wrangler deploy --env=staging`.
7674

7775
Learn about [environments in Wrangler](/workers/wrangler/environments).
7876

src/content/docs/workers/wrangler/configuration.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ To bind other Workers to your Worker, assign an array of the below object to the
867867
- `service` <Type text="string" /> <MetaInfo text="required" />
868868

869869
- The name of the Worker.
870+
- To bind to a Worker in a specific [environment](/workers/wrangler/environments), you need to append the environment name to the Worker name. This should be in the format `<worker-name>-<environment-name>`. For example, to bind to a Worker called `worker-name` in its `staging` environment, `service` should be set to `worker-name-staging`.
870871

871872
- `entrypoint` <Type text="string" /> <MetaInfo text="optional" />
872873

src/content/docs/workers/wrangler/environments.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ description: Use environments to create different configurations for the same Wo
88
import { WranglerConfig } from "~/components";
99

1010
Wrangler allows you to use environments to create different configurations for the same Worker application. Environments are configured in the Worker's [Wrangler configuration file](/workers/wrangler/configuration/).
11+
There is a default (top-level) environment and you can create named environments that provide environment-specific configuration.
1112

1213
Review the following environments flow:
1314

14-
1. You have created a Worker, named `my-worker` for example.
15+
1. Create a Worker, named `my-worker` for example.
1516
2. Create an environment, for example `dev`, in the Worker's [Wrangler configuration file](/workers/wrangler/configuration/), by adding a `[env.<ENV_NAME>]` section.
1617

1718
<WranglerConfig>
@@ -55,7 +56,7 @@ Cloudflare effectively creates a new Worker for you when you create a Worker wit
5556

5657
[Non-inheritable keys](/workers/wrangler/configuration/#non-inheritable-keys) are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
5758

58-
[Bindings](/workers/runtime-apis/bindings/) and [environment variables](/workers/configuration/environment-variables/) must be specified per each [environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/).
59+
For example, [bindings](/workers/runtime-apis/bindings/) and [environment variables](/workers/configuration/environment-variables/) are non-inheritable, and must be specified per [environment](/workers/wrangler/environments/) in your [Wrangler configuration file](/workers/wrangler/configuration/).
5960

6061
Review the following example Wrangler file:
6162

@@ -83,8 +84,8 @@ kv_namespaces = [
8384

8485
### Service bindings
8586

86-
To use a [service binding](/workers/wrangler/configuration/#service-bindings) that targets a Worker in a specific environment, you need to include the environment in `service` field. This should be in the format `<worker-name>-<environment-name>`.
87-
In the example below, we have two Workers, both with a `staging` environment. `worker-b` has a service binding to `worker-a`. Note how the service binding in the `staging` environment points to `worker-a-staging`, whereas the top-level service binding points to `worker-a`.
87+
To use a [service binding](/workers/wrangler/configuration/#service-bindings) that targets a Worker in a specific environment, you need to append the environment name to the target Worker name in the `service` field. This should be in the format `<worker-name>-<environment-name>`.
88+
In the example below, we have two Workers, both with a `staging` environment. `worker-b` has a service binding to `worker-a`. Note how the `service` field in the `staging` environment points to `worker-a-staging`, whereas the top-level service binding points to `worker-a`.
8889

8990
<WranglerConfig>
9091

0 commit comments

Comments
 (0)