A simple CLI that parses arbritrary JSON to the HCL format of tfvars files.
go get github.com/imjoshholloway/json2tfvars
Pipe some json in:
echo '{ "string": "value", "object": { "key": { "subkey": "value" }, "key2": { "subkey2": "value" } }}' | json2tfvars
string = "value"
object = { key = { subkey = "value" }, key2 = { subkey2 = "value" } }Alternatively pass in a json file:
json2tfvars -source=path/to/file.json
In versions of [terraform][#terraform] below the currently unreleased 0.12
nested maps in json variable files are not parsed correctly. This utility
converts json payloads to the tfvars format in order to work around this
issue.
See: hashicorp/terraform#15549 for more information