Running into an issue where I need to concat lists...
# atmos
j
Running into an issue where I need to concat lists:
Copy code
vpc-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:
Copy code
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:
Copy code
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.state
a
Copy code
You 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).
Copy code
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]"""
try to play with what the AI says
the problem is the
"
before
//
in
vpc_route_table_ids
, which closes the YQ expression and leaves the default value outside
j
Found the issue and ironically it had nothing to do with that 🤦