All Projects → kvz → Json2hcl

kvz / Json2hcl

Licence: mit
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.

Labels

Projects that are alternatives of or similar to Json2hcl

Ansible Terraform
Ansible and Terraform: Better Together
Stars: ✭ 297 (-14.41%)
Mutual labels:  hcl
Kubernetes Digitalocean Terraform
📋 🌊 🌎 Setup a simple Kubernetes cluster in Digital Ocean using Terraform
Stars: ✭ 324 (-6.63%)
Mutual labels:  hcl
Govuk Aws
The GOV.UK repository for our Migration to AWS
Stars: ✭ 334 (-3.75%)
Mutual labels:  hcl
Terraform Kubestack
Terraform GitOps Framework — Everything you need to build reliable automation for AKS, EKS and GKE Kubernetes clusters in one free and open-source framework.
Stars: ✭ 300 (-13.54%)
Mutual labels:  hcl
Terraform Aws Iam
Terraform module which creates IAM resources on AWS
Stars: ✭ 314 (-9.51%)
Mutual labels:  hcl
Terraform Null Label
Terraform Module to define a consistent naming convention by (namespace, stage, name, [attributes])
Stars: ✭ 324 (-6.63%)
Mutual labels:  hcl
Terraform Ecs Fargate
A Terraform template used for provisioning web application stacks on AWS ECS Fargate
Stars: ✭ 293 (-15.56%)
Mutual labels:  hcl
Terraform Beginner To Advanced Resource
Stars: ✭ 336 (-3.17%)
Mutual labels:  hcl
Cyberrange
The Open-Source AWS Cyber Range
Stars: ✭ 318 (-8.36%)
Mutual labels:  hcl
Terraform Aws Consul
A Terraform Module for how to run Consul on AWS using Terraform and Packer
Stars: ✭ 331 (-4.61%)
Mutual labels:  hcl
Elasticsearch Cloud Deploy
Deploy Elasticsearch on the cloud easily
Stars: ✭ 308 (-11.24%)
Mutual labels:  hcl
Kubecdn
Self-hosted CDN based on Kubernetes
Stars: ✭ 314 (-9.51%)
Mutual labels:  hcl
100daysofdevops
Stars: ✭ 327 (-5.76%)
Mutual labels:  hcl
Terraform ecs fargate example
Example used on my post about ECS Fargate
Stars: ✭ 300 (-13.54%)
Mutual labels:  hcl
Hcl
HCL is the HashiCorp configuration language.
Stars: ✭ 3,749 (+980.4%)
Mutual labels:  hcl
Terraform Aws Gitlab Runner
Terraform module for AWS GitLab runners on ec2 (spot) instances
Stars: ✭ 292 (-15.85%)
Mutual labels:  hcl
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (-7.2%)
Mutual labels:  hcl
Terraform Aws Ec2 Instance
Terraform module which creates EC2 instance(s) on AWS
Stars: ✭ 344 (-0.86%)
Mutual labels:  hcl
Caf Terraform Landingzones
Cloud Adoption Framework for Azure - Terraform landing zones
Stars: ✭ 335 (-3.46%)
Mutual labels:  hcl
Terraform Aws Security Group
Terraform module which creates EC2-VPC security groups on AWS
Stars: ✭ 326 (-6.05%)
Mutual labels:  hcl

Build Status

json2hcl (and hcl2json)

Convert JSON to HCL and HCL to JSON via STDIN / STDOUT.

Warning

We don't use json2hcl anymore ourselves, so we can't invest time into it. However, we're still welcoming PRs.

Install

Check the releases for the latest version. Then it's just a matter of downloading the right one for you platform, and making the binary executable.

Linux

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

curl -SsL https://github.com/kvz/json2hcl/releases/download/v0.0.6/json2hcl_v0.0.6_linux_amd64 \
  | sudo tee /usr/local/bin/json2hcl > /dev/null && sudo chmod 755 /usr/local/bin/json2hcl && json2hcl -version

OSX

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

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

Use

Here's an example fixtures/infra.tf.json being converted to HCL:

$ json2hcl < fixtures/infra.tf.json
"output" "arn" {
  "value" = "${aws_dynamodb_table.basic-dynamodb-table.arn}"
}
... rest of HCL truncated

Typical use would be

$ json2hcl < fixtures/infra.tf.json > fixtures/infra.tf

hcl2json

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

$ json2hcl -reverse < fixtures/infra.tf
{
  "output": [
    {
      "arn": [
        {
          "value": "${aws_dynamodb_table.basic-dynamodb-table.arn}"
        }
      ]
    }, 
  ... rest of JSON truncated
  ]
}

Development

mkdir -p ~/go/src/github.com/kvz
cd ~/go/src/github.com/kvz
git clone [email protected]:kvz/json2hcl.git
cd json2hcl
go get

Why?

If you don't know HCL, read Why HCL.

As for why json2hcl and hcl2json, we're building a tool called Frey that marries multiple underlying tools. We'd like configuration previously written in YAML or TOML to now be in HCL now as well. It's easy enough to convert the mentioned formats to JSON, and strictly speaking HCL is already able to read JSON natively, so why the extra step?

We're doing this for readability and maintainability, we wanted to save our infra recipes as HCL directly in our repos, instead of only having machine readable intermediate JSON that we'd need to hack on. This saves time spotting problems, and makes the experience somewhat enjoyable even.

In the off-chance you too have machine-readable JSON and are interested in converting that to the more human-being friendly HCL format, we thought we'd share this.

It's no rocket science, we're using already available HashiCorp libraries to support the conversion, HashiCorp could have easily released their own tools around this, and perhaps they will, but so far, they haven't.

Changelog

Ideabox (Unplanned)

  • [ ] Give the README.md some love

v0.0.7 (Unreleased)

  • [ ] Tests

v0.0.6 (2016-09-06)

  • [x] Deprecate goxc in favor of native builds

v0.0.5 (2016-09-06)

  • [x] Add hcl2json via the -reverse flag

v0.0.4 (2016-09-05)

  • [x] Error handling
  • [x] Cross-compiling and shipping releases

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].