How to process datasources created with iteraror

I create multiple SSM data sources with an iterator. Each of them has value json encoded list of strings. I want to merge all those lists in a single one:

const parameters = new DataAwsSsmParameter(this.stack, `someid`, {
            forEach: iterator,
            name: `prefix/${iterator.value}`,
            provider: provider
        })

Something like

flatten([for v in parameters:  jsondecode(v.value)])

But all my attempts lead to

Because data.aws_ssm_parameter.someId (someId) has "for_each" set,  its attributes must be accessed on specific instances.

Hi @Truefiber :wave:

This is not yet supported directly through Iterators, unfortunately: Support accessing resources created by an iterator · Issue #2024 · hashicorp/terraform-cdk · GitHub

The only way to currently achieve this would be by using the escape hatch and defining raw overrides.

1 Like