▲ | antonymoose 15 hours ago | |
Working with Terraform, and needing to handle the complexity of our per-client deployments at work, I ended up creating a bash layer that takes N number of JSON files, performs a deep merge, and spits out a .tfvars file. As you’ve said, all I did was fork a JSON.stringify function and swap colon for equals. Anyone have a better solution they’ve worked with? Edit: Why the downvotes? Terraform is using HCL? Are we talking a different HCL here? | ||
▲ | zanecodes 13 hours ago | parent [-] | |
You can directly pass JSON to Terraform by putting it in a `.tfvars.json` file [1], as far as I can tell this has been supported since v0.5.0 which released in May 2015. Terraform doesn't have a built-in deep merge function, but it will merge `.tfvars.json` files in the order given on the CLI, if you specify multiple `-var-file` arguments. For what it's worth, as of Terraform 1.8, you can also use functions from third-party providers like isometry/deepmerge [2] to perform a deep merge. [1] https://developer.hashicorp.com/terraform/language/parameter... [2] https://registry.terraform.io/providers/isometry/deepmerge/l... |