Flat data structure
As the flat data structure is made up of a root loop of records, only specific portions of a single template file can be scanned for data interpolation.
Each interpolated area of the template is called an injection area and is delimited by a loop templating structure.
Input file content
terraform {
required_providers {
($)[
{{name}} = {
source = "{{namespace}}/{{name}}"
version = "{{version}}"
}
]
}
}Data structure
[
{
"namespace": "hashicorp",
"name": "aws",
"version": "2.0.1"
},
{
"namespace": "hashicorp",
"name": "azure",
"version": "3.4.2"
},
{
"namespace": "hashicorp",
"name": "google",
"version": "1.2.1"
}
]Result
terraform {
required_providers {
azure = {
source = 'az/azure'
version = '1.0.0'
}
aws = {
source = 'aws/aws'
version = '1.1.0'
}
gcp = {
source = 'gcp/gcp'
version = '1.2.0'
}
}
}Last updated
Was this helpful?