From 29f9e9a1f5590bdecdc7eebbad0aa299baa63244 Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 16 Jan 2025 18:50:20 -0500 Subject: [PATCH] updates --- pkg/describe/describe_component_test.go | 12 -------- .../yaml-functions/terraform.output.mdx | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pkg/describe/describe_component_test.go b/pkg/describe/describe_component_test.go index 09000f12e..03904a92c 100644 --- a/pkg/describe/describe_component_test.go +++ b/pkg/describe/describe_component_test.go @@ -90,15 +90,3 @@ func TestDescribeComponent7(t *testing.T) { assert.Nil(t, err) t.Log(componentSectionYaml) } - -func TestDescribeComponent8(t *testing.T) { - component := "template-functions-test2" - stack := "tenant1-ue2-prod" - - componentSection, err := ExecuteDescribeComponent(component, stack, true) - assert.Nil(t, err) - - componentSectionYaml, err := u.ConvertToYAML(componentSection) - assert.Nil(t, err) - t.Log(componentSectionYaml) -} diff --git a/website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx b/website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx index 6d4bd7a51..9f6e584f2 100644 --- a/website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx +++ b/website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx @@ -45,6 +45,30 @@ Atmos processes the templates first, and then executes the `!terraform.output` f the function dynamically. ::: +## Using YQ Expressions to retrieve items from complex output types + +To retrieve items from complex output types such as maps and lists, or do any kind of filtering or querying, +you can utilize [YQ](https://mikefarah.gitbook.io/yq) expressions. + +For example: + +- Retrieve the first item from a list + +```yaml +subnet_id1: !terraform.output vpc .private_subnet_ids[0] +``` + +- Read a key from a map + +```yaml +username: !terraform.output config .config_map.username +``` + +For more details, review the following docs: + +- [YQ Guide](https://mikefarah.gitbook.io/yq) +- [YQ Recipes](https://mikefarah.gitbook.io/yq/recipes) + ## Examples @@ -60,8 +84,12 @@ components: security_group_id3: !terraform.output security-group/lambda3 {{ .atmos_stack }} id # Output of type list subnet_ids: !terraform.output vpc private_subnet_ids + # Use a YQ expression to get an item from the list + subnet_id1: !terraform.output vpc .private_subnet_ids[0] # Output of type map config_map: !terraform.output config {{ .stack }} config_map + # Use a YQ expression to get a value from the map + username: !terraform.output config .config_map.username ```