Git Product home page Git Product logo

hcl2json's Introduction

hcl2json

Convert HCL to JSON , and vice versa. Use the latest version hcl source to build.

Build Status

Language

简体中文|English

Install

Linux

Here's how it could look for 64 bits Linux, if you wanted hcl2json available globally inside /usr/local/bin:

curl -SsL https://github.com/gorpher/hcl2json/releases/download/v1.0.0/hcl2json_v1.0.0_linux_amd64 \
  | sudo tee /usr/local/bin/hcl2json > /dev/null && sudo chmod 755 /usr/local/bin/hcl2json && hcl2json -version

OSX

Here's how it could look for 64 bits Darwin, if you wanted hcl2json available globally inside /usr/local/bin:

curl -SsL https://github.com/gorpher/hcl2json/releases/download/v0.0.6/hcl2json_v1.0.1_darwin_amd64 \
  | sudo tee /usr/local/bin/hcl2json > /dev/null && sudo chmod 755 /usr/local/bin/hcl2json && hcl2json -version

Use

Single file convert

Here's an example test-fixtures/hcl_outputs/outputs.tf being converted to JSON:

$ hcl2json -i test-fixtures/hcl_outputs/outputs.tf

{
  "output": [
    {
      "public_ip": [
        {
          "value": "${tencentcloud_instance.cvm_test[0].public_ip}"
        }
      ]
    }
  ]
}

Typical use would be

$ hcl2json -i test-fixtures/hcl_outputs/outputs.tf -o outputs.tf.json

Multi files convert

$ hcl2json -i test-fixtures/ -o test-fixtures-10/

json2hcl

As a bonus, the conversion the other way around is also supported via the -reverse flag:

$ hcl2json -i test-fixtures/json_outputs/outputs.tf.json -reverse


output "public_ip" {
  value = "${tencentcloud_instance.cvm_test[0].public_ip}"
}

Development

git clone [email protected]:gorpher/hcl2json.git
cd hcl2json
go mod tidy

hcl2json's People

Contributors

gitmkn avatar gorpher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hcl2json's Issues

no convert to json

I have installed hcl2json with next command:

curl -SsL https://github.com/gorpher/hcl2json/releases/download/v1.0.0/hcl2json_v1.0.0_linux_amd64 \
  | sudo tee /usr/local/bin/hcl2json > /dev/null && sudo chmod 755 /usr/local/bin/hcl2json && hcl2json -version

the version according to output is

$ hcl2json -version
v1.0.0

when I run hcl2json -i main.tf there is no output. when I add hcl2json -i main.tf -o main.json file is created but it is empty

json2hcl works fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.