json2hcl icon indicating copy to clipboard operation
json2hcl copied to clipboard

reverse and back again not valid

Open dynnamitt opened this issue 6 years ago • 1 comments

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

dynnamitt avatar May 02 '18 09:05 dynnamitt

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

Acconut avatar May 02 '18 21:05 Acconut