Skip to content

Commit 65d9ec7

Browse files
authored
ESC Environments reference (#14634)
These changes add a more complete reference section to the ESC documentation. This reference content covers the contents of ESC environment definitions, including: - Document structure - Interpolation and reference syntax - Built-in functions - Built-in values - Providers - Rotators - Reserved properties - Sample environment definitions Fixes #14289
1 parent b06f9a6 commit 65d9ec7

25 files changed

+1124
-14
lines changed

content/docs/esc/reference/_index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Environment Definition Reference
3+
title_tag: Environment Definition Reference
4+
h1: Environment Definition Reference
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-home
9+
identifier: esc-reference
10+
weight: 5
11+
aliases:
12+
- /docs/esc/syntax-reference
13+
---
14+
15+
This is a reference for the various constructs defined by ESC.
16+
17+
## Reference summary
18+
19+
The ESC Environment reference is divided into the following sections:
20+
21+
- __Top-level keys__: These are the different top-level document keys defined by the ESC language. Each key has its own well-defined semantics. For more information, see the [top-level key reference](/docs/esc/reference/top-level-keys).
22+
- __Interpolations and references__: Interpolations and references are additional syntactical constructs ESC layers on top of YAML to enable users to reuse property values. For more information, see the [interpolation and references syntax reference](/docs/esc/reference/interpolations-and-references).
23+
- __Built-in functions__: These are the different built-in functions defined by the ESC language. These functions allow you to perform common tasks such as encoding and decoding values and manipulating strings. For more information, see the [built-in functions reference](/docs/esc/reference/builtin-functions).
24+
- __Built-in properties__: These are the different predefined properties available to [interpolations and references](/docs/esc/reference/interpolations-and-references). For more information, see the [built-in values reference](/docs/esc/reference/builtin-values).
25+
- __Providers__: These are the different providers that allow dynamic access to credentials, configuration, and secrets stored outside of ESC. Each provider has its own set of inputs that affect its behavior. For more information, see the [providers reference](/docs/esc/reference/providers).
26+
- __Rotators__: These are the different rotators that allow ESC to rotate credentials, configuration, and secrets stored outside of ESC. Each rotator has its own set of inputs that affect its behavior. For more information, see the [rotators reference](/docs/esc/reference/rotators).
27+
- __Reserved properties__: These are the different environment properties that are interpreted by the [`esc` CLI](/docs/install/esc/) and other ESC consumers (e.g. the [`pulumi` CLI](/docs/install/)). The semantics of these properties are defined by conventions amongst consumers of ESC environments. For more information, see the [reserved property reference](/docs/esc/reference/reserved-properties).
28+
- __Sample environment definition__: This is a sample environment definition that demonstrates many of the constructs described in the other reference sections. For more information, see the [sample environment definition reference](/docs/esc/reference/sample-environment-definition).
29+
30+
Each ESC environment is a YAML document that defines the structure and values produced when the environment is evaluated (also referred to as _opened_). For more information see the [high-level Environments documentation](/docs/esc/environments).
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Built-in Functions
3+
title_tag: Built-in Functions
4+
h1: Built-in Functions
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-reference
9+
identifier: esc-ref-builtin-functions
10+
weight: 3
11+
---
12+
13+
ESC provides a number of built-in functions to help perform common value manipulations and to help access information stored outside of ESC.
14+
15+
All function invocations take the form of an object with a single key that names the function to invoke. The value of the key is the argument passed to the function. It is an error to attempt to invoke an unknown function, or for an object literal with multiple entries to contain a key with the prefix `fn::`.
16+
17+
## Functions
18+
19+
- [`fn::fromJSON`](/docs/esc/reference/builtin-functions/fn-from-json)
20+
- [`fn::fromBase64`](/docs/esc/reference/builtin-functions/fn-from-base64)
21+
- [`fn::join`](/docs/esc/reference/builtin-functions/fn-join)
22+
- [`fn::open`](/docs/esc/reference/builtin-functions/fn-open)
23+
- [`fn::rotate`](/docs/esc/reference/builtin-functions/fn-rotate)
24+
- [`fn::secret`](/docs/esc/reference/builtin-functions/fn-secret)
25+
- [`fn::toBase64`](/docs/esc/reference/builtin-functions/fn-to-base64)
26+
- [`fn::toJSON`](/docs/esc/reference/builtin-functions/fn-to-json)
27+
- [`fn::toString`](/docs/esc/reference/builtin-functions/fn-to-string)
28+
29+
## Examples
30+
31+
### Valid function invocation
32+
33+
```yaml
34+
valid:
35+
fn::join: [ " ", [ "hello", "world" ] ]
36+
```
37+
38+
### Too many keys
39+
40+
```yaml
41+
tooManyKeys:
42+
fn::join: [ " ", [ "hello", "world" ] ]
43+
fn::toString: { "hello": "world" }
44+
```
45+
46+
### Unknown function
47+
48+
```yaml
49+
unknownFunction:
50+
fn::undefined: {}
51+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: fn::fromBase64
3+
title_tag: fn::fromBase64
4+
h1: fn::fromBase64
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-ref-builtin-functions
9+
identifier: esc-ref-fn-from-base64
10+
weight: 2
11+
---
12+
13+
The `fn::fromBase64` built-in function decodes its input into a binary value. This can be used to realize binary values that are stored as Base64-encoded (often for use with the [`files` well-known property](/docs/esc/reference/well-known-properties/files). If the input to `fn::fromBase64` is a secret, the decoded value is also a secret.
14+
15+
## Declaration
16+
17+
```yaml
18+
fn::fromBase64: value-to-decode
19+
```
20+
21+
### Parameters
22+
23+
| Property | Type | Description |
24+
|-------------------|--------|-------------------------------------------------------------------|
25+
| `value-to-decode` | string | The base64-encoded value.
26+
27+
### Returns
28+
29+
The decoded data.
30+
31+
## Example
32+
33+
### Definition
34+
35+
```yaml
36+
values:
37+
binary-data:
38+
fn::fromBase64: aGVsbG8sIHdvcmxkIQo=
39+
```
40+
41+
### Evaluated result
42+
43+
```json
44+
{
45+
"binary-data": "hello, world!"
46+
}
47+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: fn::fromJSON
3+
title_tag: fn::fromJSON
4+
h1: fn::fromJSON
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-ref-builtin-functions
9+
identifier: esc-ref-fn-from-json
10+
weight: 1
11+
---
12+
13+
The `fn::fromJSON` built-in function decodes a value from its JSON representation. This can be used to expand JSON values that are stored as scalar strings into complex values. If the input to `fn::fromJSON` is a secret, all of the decoded values are also secrets.
14+
15+
## Declaration
16+
17+
```yaml
18+
fn::fromJSON: value-to-decode
19+
```
20+
21+
### Parameters
22+
23+
| Property | Type | Description |
24+
|-------------------|--------|-------------------------------------------------------------------|
25+
| `value-to-decode` | string | The JSON value to decode.
26+
27+
### Returns
28+
29+
The decoded value.
30+
31+
## Example
32+
33+
### Definition
34+
35+
```yaml
36+
values:
37+
json-object:
38+
fn::fromJSON: "{\"hello\": \"world\"}"
39+
```
40+
41+
### Evaluated result
42+
43+
```json
44+
{
45+
"json-object": {
46+
"hello": "world"
47+
}
48+
}
49+
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: fn::join
3+
title_tag: fn::join
4+
h1: fn::join
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-ref-builtin-functions
9+
identifier: esc-ref-fn-join
10+
weight: 3
11+
---
12+
13+
The `fn::join` built-in function joins the elements of a list of strings using a given delimiter. If any input to `fn::join` is a secret, the result is also a secret.
14+
15+
## Declaration
16+
17+
```yaml
18+
fn::join: [ delimiter, values ]
19+
```
20+
21+
### Parameters
22+
23+
| Property | Type | Description |
24+
|-------------|--------------|-------------------------------------------------------------------|
25+
| `delimiter` | string | The delimiter to use when joining values
26+
| `values` | List<string> | The list of strings to join
27+
28+
### Returns
29+
30+
The elements of `values` joined by `delimiter`.
31+
32+
## Example
33+
34+
### Definition
35+
36+
```yaml
37+
values:
38+
list-of-strings:
39+
- one
40+
- two
41+
- three
42+
joined:
43+
fn::join: [ ", ", ${list-of-strings} ]
44+
```
45+
46+
### Evaluated result
47+
48+
```json
49+
{
50+
"list-of-strings": [
51+
"one",
52+
"two",
53+
"three"
54+
],
55+
"joined": "one, two, three"
56+
}
57+
```
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: fn::open
3+
title_tag: fn::open
4+
h1: fn::open
5+
meta_desc: Pulumi ESC allows you to compose and manage hierarchical collections of configuration and secrets and consume them in various ways.
6+
menu:
7+
esc:
8+
parent: esc-ref-builtin-functions
9+
identifier: esc-ref-fn-open
10+
weight: 4
11+
---
12+
13+
The `fn::open` built-in function invokes a [provider](/docs/esc/reference/providers/) to fetch values from outside of ESC.
14+
15+
## Declaration
16+
17+
```yaml
18+
fn::open:
19+
provider: name
20+
inputs: inputs
21+
```
22+
23+
### Short form
24+
25+
In addition to the long form syntax, `fn::open` can be invoked using the short form `fn::open::name` with the inputs provided directly:
26+
27+
```yaml
28+
fn::open::name: inputs
29+
```
30+
31+
### Parameters
32+
33+
| Property | Type | Description |
34+
|-------------|--------------|-------------------------------------------------------------------|
35+
| `name` | string | The name of the provider to open.
36+
| `inputs` | any | The inputs to the provider. The exact type is provider-dependent.
37+
38+
### Returns
39+
40+
The return value of `fn::open` is dependent on the provider being opened.
41+
42+
## Example
43+
44+
### Long form
45+
46+
```yaml
47+
values:
48+
aws:
49+
login:
50+
fn::open:
51+
provider: aws-login
52+
inputs:
53+
oidc:
54+
...
55+
```
56+
57+
### Short form
58+
59+
```yaml
60+
values:
61+
aws:
62+
login:
63+
fn::open::aws-login:
64+
oidc:
65+
...
66+
```
67+
68+
### Evaluated result
69+
70+
```json
71+
{
72+
"aws": {
73+
"login": {
74+
"AWS_ACCESS_KEY_ID": ...,
75+
"AWS_SECRET_ACCESS_KEY": ...,
76+
"AWS_SESSION_TOKEN": ...
77+
}
78+
}
79+
}
80+
```

0 commit comments

Comments
 (0)