Example using HCL2JSON from NPM on osx
$cat ./0-terraform.tf
terraform {
required_version = "= 0.11.11"
}
$ hcl2json ./0-terraform.tf
{
"terraform": {
"required_version": "= 0.11.11"
}
}
Here are the same file contents and the JSON output using your HCL2JSON on a Ubuntu Trusty docker container.
root@0de8e7724845:~# cat test.tf
terraform {
required_version = "= 0.11.11"
}
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf
{
"terraform": [
{
"required_version": "= 0.11.11"
}
]
}
Notice in the first example that there are no [] around the terraform subkeys. When I pipe this output to jq -r '.terraform' it works as expected but if I filter for a subkey like '.terraform.required_version' I get this error which I believe is due to the [] output from your tool.
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform'
[
{
"required_version": "= 0.11.11"
}
]
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform.required_version'
jq:
error: Cannot index array with string
Example using HCL2JSON from NPM on osx
$cat ./0-terraform.tf
$ hcl2json ./0-terraform.tf
Here are the same file contents and the JSON output using your HCL2JSON on a Ubuntu Trusty docker container.
root@0de8e7724845:~# cat test.tf
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf
Notice in the first example that there are no [] around the terraform subkeys. When I pipe this output to jq -r '.terraform' it works as expected but if I filter for a subkey like '.terraform.required_version' I get this error which I believe is due to the [] output from your tool.
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform'
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform.required_version'