Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 30 additions & 0 deletions website/docs/manifest_fields/name.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,34 @@ name: kubernetes-the-hard-way
Don't embed any environment symbols or designators in the `name` field, these are sourced at deploy time from the `STACK_ENV` argument to the `build`, `test` or `teardown` commands, and exposed for use in resource or property values as a global variable called `stack_env`.

:::

## Built-in variables

The following variables are automatically available in all resource query templates and property values without needing to be defined in `globals`:

| Variable | Description |
|---|---|
| `stack_name` | The name of the stack (from the `name` field in the manifest) |
| `stack_env` | The target environment, supplied as the `STACK_ENV` argument to `build`, `test` or `teardown` |
| `resource_name` | The name of the **current resource** being processed (from the `resource.name` field) |

### `resource_name`

The `resource_name` variable is set automatically for each resource as it is processed. This is useful when you need to reference the current resource's name in property values or query templates — for example, to construct unique identifiers or generate resource-specific naming conventions.

```yaml
resources:
- name: example_vpc
props:
- name: vpc_name
value: "{{ stack_name }}-{{ stack_env }}-{{ resource_name }}"
```

In this example, when deploying to the `dev` environment with a stack named `my-stack`, the `vpc_name` value would resolve to `my-stack-dev-example_vpc`.

:::note

`resource_name` changes for each resource as the manifest is processed top-down. It always reflects the name of the resource currently being deployed, tested or torn down.

:::
10 changes: 8 additions & 2 deletions website/docs/manifest_fields/resources/name.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import LeftAlignedTable from '@site/src/components/LeftAlignedTable';

<LeftAlignedTable type="string" required={true} />

The name of the resource
The name of the resource. This value is automatically exposed as the built-in variable `resource_name` during processing, making it available in property values and query templates for the current resource.

<File name='stackql_manifest.yml'>

Expand All @@ -13,4 +13,10 @@ resources:
...
```

</File>
</File>

:::tip

You can reference the current resource's name using `{{ resource_name }}` in property values or query templates. See [Built-in variables](../../../manifest-file#name) for more details.

:::