json2hcl
json2hcl copied to clipboard
reverse and back again not valid
i cannot convert a tf to json and back again .. ( json2hcl -reverse < a.tf | json2hcl > b.tf )
a.tf ;
"terraform" = { "backend" "local" { "key" = "x.tfstate" } }
-- result b.tf
"terraform" = { "backend" = { "local" = { "key" = "x.tfstate" } } }
once back as b.tf iIT IS NOT valid syntax
Error loading ..../.../t2.tf: Error reading backend config for terraform block: position -: 'backend' must be followed by exactly one string: a type
Similar errors have been reported many times (e.g. https://github.com/kvz/json2hcl/issues/4). The problem is that the official HCL parser library that we use, does not produce the same output as you input because there are multiple serialized version for a given HCL file. This comment contains two links with more details: https://github.com/kvz/json2hcl/issues/4#issuecomment-275513256