Skip to content

Commit

Permalink
Add docs on esc/iac dependency tracking (#13382)
Browse files Browse the repository at this point in the history
* Update esc examples to use projects

* Add tip on stack/esc dep tracking

* fixup
  • Loading branch information
seanyeh authored Nov 19, 2024
1 parent b9693f5 commit 32371c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
26 changes: 13 additions & 13 deletions content/docs/esc/environments/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Different applications are often configured in similar ways and with common valu

To address these challenges, Pulumi ESC allows you to identify common or closely related configuration settings and define them only once, as individual environments, and then _import_ those environments into other, more specialized environments as needed. Imports also allow you to expose certain environments without having to distribute any concrete values and to delegate responsibility for particular environments to other teams in your organization. Environments can import both static and dynamic values, including secrets, from any number of other environments.

In the following example, two environments, `aws-dev` and `stripe-dev`, are used to compose a third environment, `myapp-dev`:
In the following example, two environments, `aws/dev` and `stripe/dev`, are used to compose a third environment, `myapp/dev`:

```yaml
# myorg/aws-dev
# myorg/aws/dev
values:
aws:
region: us-west-2
Expand All @@ -34,24 +34,24 @@ values:
```
```yaml
# myorg/stripe-dev
# myorg/stripe/dev
values:
stripe:
apiURL: https://api.stripe.com
apiKey:
fn::secret: sk_XemWAl12i4x3hZhp4vBKDEXAMPLE
```
The application-specific `myapp-dev` environment then `imports` these two environments and use their settings to compose new values:
The application-specific `myapp/dev` environment then `imports` these two environments and use their settings to compose new values:

```yaml
# myorg/myapp-dev
# myorg/myapp/dev
imports:
- aws-dev
- stripe-dev
- aws/dev
- stripe/dev
values:
greeting: Hello from the dev environment!
greeting: Hello from the myapp/dev environment!
environmentVariables:
AWS_ACCESS_KEY_ID: ${aws.login.accessKeyId}
Expand All @@ -61,19 +61,19 @@ values:
GREETING: ${greeting}
```

Finally, `esc run` renders `myapp-dev`'s environment variables for use on the command line:
Finally, `esc run` renders `myapp/dev`'s environment variables for use on the command line:

```bash
$ esc run myorg/myapp-dev -- bash -c 'echo $GREETING'
$ esc run myorg/myapp/dev -- bash -c 'echo $GREETING'
Hello from the dev environment!
$ esc run myorg/myapp-dev -- bash -c 'echo $STRIPE_API_URL'
$ esc run myorg/myapp/dev -- bash -c 'echo $STRIPE_API_URL'
https://api.stripe.com
$ esc run myorg/myapp-dev -- bash -c 'echo $STRIPE_API_KEY'
$ esc run myorg/myapp/dev -- bash -c 'echo $STRIPE_API_KEY'
[secret]
$ esc run myorg/myapp-dev -- bash -c 'echo $AWS_SECRET_ACCESS_KEY'
$ esc run myorg/myapp/dev -- bash -c 'echo $AWS_SECRET_ACCESS_KEY'
[secret]
$ echo "'$GREETING'"
Expand Down
26 changes: 20 additions & 6 deletions content/docs/esc/integrations/infrastructure/pulumi-iac/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ menu:

With support for Pulumi ESC built into the Pulumi CLI, you can expose an environment's settings and secrets to any or all of your Pulumi stacks, bypassing the need to define and maintain individual configuration settings or secrets "locally" in Pulumi config files. The optional `pulumiConfig` key enables this.

The following example updates the `myorg/myapp-dev` environment by adding a `pulumiConfig` block. This block specifies the [Pulumi configuration](/docs/concepts/config/) settings to expose to the Pulumi stack at runtime:
{{% notes type="info" %}}
The [pulumi](/docs/iac/cli/) CLI (as of v3.139.0) now tracks ESC environments used in stack updates. You can view which ESC environments were used in your updates on the Stack Overview page within the Pulumi Cloud Console.
{{% /notes %}}

The following example updates the `myorg/myapp/dev` environment by adding a `pulumiConfig` block. This block specifies the [Pulumi configuration](/docs/concepts/config/) settings to expose to the Pulumi stack at runtime:

```yaml
# myorg/myapp-dev
# myorg/myapp/dev
imports:
- aws-dev
- stripe-dev
- aws/dev
- stripe/dev

values:
greeting: Hello from the dev environment!
greeting: Hello from the myapp/dev environment!

environmentVariables:
AWS_ACCESS_KEY_ID: ${aws.login.accessKeyId}
Expand All @@ -43,7 +47,7 @@ Any stack belonging to the `myorg` organization can inherit these settings by ad
```yaml
# Pulumi.dev.yaml
environment:
- myapp-dev
- myapp/dev
```

Values are accessible using the standard [configuration API](/docs/concepts/config/#code):
Expand Down Expand Up @@ -86,6 +90,16 @@ export const url = functionUrl.functionUrl;

Stacks may only read from environments that belong to the same Pulumi organization.

### Convert existing Stack Config to an ESC Environment

To convert your existing stack config to a new ESC Environment, you can use the pulumi CLI to run the following:

```shell
pulumi config env init
```

See [here](/docs/iac/cli/commands/pulumi_config_env_init/) for more information.

### Automation API integration

You can use ESC with [Automation API](/docs/using-pulumi/automation-api/) in [Node](/docs/reference/pkg/nodejs/pulumi/pulumi/classes/automation.Stack.html#addEnvironments), [Go](https://pkg.go.dev/github.com/pulumi/pulumi/sdk/[email protected]/go/auto#LocalWorkspace.AddEnvironments), and [Python](docs/reference/pkg/python/pulumi/#pulumi.automation.LocalWorkspace.add_environments). The following methods are supported today:
Expand Down

0 comments on commit 32371c2

Please sign in to comment.