A high-performance CLI tool for converting Terraform HCL files to JSON format, designed for seamless integration with TerraForce CI/CD pipelines to enforce security policies
Concurrent processing with configurable goroutines for optimal conversion speed
Seamless integration with GitHub Actions, GitLab CI, Jenkins, and other CI/CD platforms
Full support for *.tf and *.tfvars files with detailed error reporting
Designed to work seamlessly with TerraForce in your IaC security pipeline
Choose the right version for your platform
% hcl2json
_ _ ____ _
| |__ ___| |___ \ (_)___ ___ _ __
| '_ \ / __| | __) || / __|/ _ \| '_ \
| | | | (__| |/ __/ | \__ \ (_) | | | |
|_| |_|\___|_|_____|/ |___/\___/|_| |_|
|__/
Scan directories for Terraform HCL files and convert to JSON
------------------------------------------------------------
author: Henry Bravo | date: January 2025 | version: 1.0.0
Usage:
hcl2json [flags]
hcl2json [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version number of hcl2json
Flags:
-d, --debug Enable debug mode
-D, --directory string Specify the directory to scan
-h, --help help for hcl2json
-m, --max-concurrency int Maximum number of concurrent goroutines (default 10)
-r, --recursive Scan subdirectories recursively
hcl2json --directory /path/to/terraform/files --recursive
# GitHub Actions Example
name: Terraform Security Scan
on: [push, pull_request]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Convert HCL to JSON
run: |
hcl2json --directory . --recursive --debug
- name: Run TerraForce Scan
run: |
terraforce pre-plan policy.yml main.tf.json
resource "aws_instance" "example" {
ami = "ami-12345678"
instance_type = "t2.micro"
tags = {
Name = "example-instance"
Environment = "production"
}
}
{
"resource": {
"aws_instance": {
"example": {
"ami": "ami-12345678",
"instance_type": "t2.micro",
"tags": {
"Name": "example-instance",
"Environment": "production"
}
}
}
}
}
This notice is to clarify the relationship between hcl2json, developed by Henry Bravo, and HashiCorp (https://www.hashicorp.com).
HashiCorp, Terraform, and HCL are registered trademarks of HashiCorp, Inc. The use of these terms in this notice does not imply any endorsement or affiliation.
For any inquiries, support requests, or feedback regarding hcl2json, please contact Henry directly: