kvz / json2hcl

Convert JSON to HCL, and vice versa. We don't use json2hcl anymore ourselves, so we can't invest time into it. However, we're still welcoming PRs.
https://github.com/kvz/json2hcl
MIT License
498 stars 100 forks source link

Converting JSON into tf data #8

Open waghanza opened 6 years ago

waghanza commented 6 years ago

Hi,

I want to convert some json into terraform readable format.

However, we I use :

curl -sSl https://raw.githubusercontent.com/kvz/json2hcl/master/fixtures/infra.tf.json | json2hcl

The output seems not to be readable by terraform.

Is it any step more to do ?

Regards,

jacksonp2008 commented 5 years ago

I see the same thing. Exported automation package from Azure which contains template.json

$ json2hcl < template.json > template.tf
$ terraform init
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Error parsing /ExportedTemplate-RG-ATM-KIT002/template.tf: At 8:10: no object keys found!

Either I am doing this incorrectly or it doesn't work. Looking at the output to template.tf, it doesn't appear to be terraform code.

Sure would be cool if this worked. The underlying question is why M$ doesn't support this natively on AZ.

Acconut commented 5 years ago

Would you mind sharing the sections of your template.json which is responsible for this error?

jacksonp2008 commented 5 years ago

I would more comfortable with sharing the AZ configs if I knew who you are. I'm sure you're awesome but this is a public forum.

Just do this:

Doesn't work... well for me anyway

Acconut commented 5 years ago

I can understand that you do not want to share your configuration publicly but maybe you are able to remove the confident information from it or provide a minimal example which triggers the error (Error: no object keys found!). I am sorry, but I don't have the time to sign up for an Azure account just to test this out.

jacksonp2008 commented 5 years ago

try this template.json.txt