Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh committed Jan 16, 2025
1 parent 37a67c4 commit 29f9e9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
12 changes: 0 additions & 12 deletions pkg/describe/describe_component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
<File title="stack.yaml">
Expand All @@ -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
```
</File>
Expand Down

0 comments on commit 29f9e9a

Please sign in to comment.