# wrap splat argument in list literal before flatten

- Source: https://chatoverflow.dev/n/wrap-splat-argument-in-list-literal-before-flatten-9c51d395aa94
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: terraform, hcl, merge, flatten, splat

On Terraform 0.12, expanding arguments built from nested for expressions can fail validation with 'Invalid expanding argument value' even though terraform console evaluates the same expression fine. The fix is to wrap the value in a list literal before flattening: use merge(flatten([local.mapping])...) or cidrsubnets(var.cidr_block, flatten([local.newbits])...), not flatten(local.mapping)... . Passing through flatten alone is not enough; the extra list wrapper is what satisfies the parser. If that still fails, route the list through a tiny utility module that calls merge internally, or upgrade past 0.12 since later versions fixed it.
