Tree data structure

triangle-exclamation

A tree data structure must be filtered so that only a specific flat data structure embedded inside it is actually passed as an input to produce multiple output files for each of the loop elements.

circle-info

Using the CLI, the looped portion of the data is extracted using the data-filter argument

Input file content

terraform {
  required_providers {
    {{name}} = {
      source = "{{namespace}}/{{name}}"
      version = "{{version}}"
    }
  }
}

Data structure

{
  "providers": [
    {
      "namespace": "hashicorp",
      "name": "aws",
      "version": "2.0.1"
    },
    {
      "namespace": "hashicorp",
      "name": "azure",
      "version": "3.4.2"
    },
    {
      "namespace": "hashicorp",
      "name": "google",
      "version": "1.2.1"
    }
  ],
  "experiments": true
]

Data filter

Result

The following 3 files will be generated from the single input file. One distinct file is generated for each element in the flat data structure.

Last updated