From 2f5d7f441095f61d102ca66e5a0391be75dfe982 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 04:38:03 +0000 Subject: [PATCH] Document resource_name built-in variable - Add "Built-in variables" section to manifest name.mdx documenting stack_name, stack_env, and resource_name with a table and example - Update resource.name field docs to note that the value is exposed as the resource_name variable https://claude.ai/code/session_01FikwxWpZdvhtNbECVWJiqK --- website/docs/manifest_fields/name.mdx | 30 +++++++++++++++++++ .../docs/manifest_fields/resources/name.mdx | 10 +++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/website/docs/manifest_fields/name.mdx b/website/docs/manifest_fields/name.mdx index bb2733b..3e59cc0 100644 --- a/website/docs/manifest_fields/name.mdx +++ b/website/docs/manifest_fields/name.mdx @@ -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. + ::: \ No newline at end of file diff --git a/website/docs/manifest_fields/resources/name.mdx b/website/docs/manifest_fields/resources/name.mdx index 6adab0d..4b1bcad 100644 --- a/website/docs/manifest_fields/resources/name.mdx +++ b/website/docs/manifest_fields/resources/name.mdx @@ -3,7 +3,7 @@ import LeftAlignedTable from '@site/src/components/LeftAlignedTable'; -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. @@ -13,4 +13,10 @@ resources: ... ``` - \ No newline at end of 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. + +::: \ No newline at end of file