Jonathan Rose
08/20/2025, 2:19 PMvpc-attachments:
vars:
vpc_attachments:
vpc:
subnet_ids: !terraform.state vpc "intra_subnets // ""[MOCK__subnet_0, MOCK__subnet_1, MOCK__subnet_2]"""
# Atmos supports YQ expressions on state outputs https://atmos.tools/core-concepts/stacks/yaml-functions/terraform.state#using-yq-expressions-to-retrieve-items-from-complex-output-types
# See YQ merge for concatenating multiple lists https://mikefarah.gitbook.io/yq/operators/add#concatenate-arrays
vpc_route_table_ids: !terraform.state vpc ".private_route_table_ids + .intra_route_table_ids + .database_route_table_ids" // ""[MOCK__route_table_id_0, MOCK__route_table_id_1, MOCK__route_table_id_2]"""
tgw_vpc_attachment_tags:
Name: "{{ .atmos_stack }}-tgw-attachment"
But I am getting the following error:
ProcessYAMLConfigFile: Merge: Deep-merge the stack manifest and all the imports: Error: cannot override two slices with different type ([]interface {}, string)
Here is the documentation I am using as a reference:
https://mikefarah.gitbook.io/yq/operators/add#concatenate-arrays
Any thoughts? Not sure if it's a missing quote or list concatenantes won't work when getting values from !terraform.stateAndriy Knysh (Cloud Posse)
08/20/2025, 3:00 PMYou tripped over operator placement + types.
In the working one, the fallback // lives inside the quoted YQ expression, so the function returns a list.
In the failing one, the // is outside the quotes, so Atmos treats the fallback as a YAML string (e.g., "["MOCK__..."]"), which clashes with the real value's type (list) when merging: []interface{} vs string.
Fix: keep the fallback inside the YQ expression (or make sure the fallback is parsed as a list).Andriy Knysh (Cloud Posse)
08/20/2025, 3:00 PMvpc_route_table_ids: !terraform.state vpc "
(.private_route_table_ids // [])
+ (.intra_route_table_ids // [])
+ (.database_route_table_ids // [])
// ""[MOCK__route_table_id_0, MOCK__route_table_id_1, MOCK__route_table_id_2]"""Andriy Knysh (Cloud Posse)
08/20/2025, 3:01 PMAndriy Knysh (Cloud Posse)
08/20/2025, 3:05 PM" before // in vpc_route_table_ids , which closes the YQ expression and leaves the default value outsideJonathan Rose
08/21/2025, 12:49 AM