Skip to content

swnia/terraform-hcl-parser-node

 
 

Repository files navigation

Go

Terraform HCL Parser for Node.js

Using gopherjs to transpile Hashicorp's HCL into javascript.

Inspired by anhldbk/hcl-parser

Usage

const fs = require('fs');
const parser = require('@evops/hcl-terraform-parser');

const content = fs.readFileSync('main.tf');
const hclFile = parser.parse(content);

hclFile is a JSON object with following structure:

{
  path: '<virtual>',
  variables: {
    test: {
      name: 'test',
      default: 'Default value',
      required: false,
      pos: [Object]
    }
  },
  outputs: { test: { name: 'test', pos: [Object] } },
  required_providers: { test: { version_constraints: [Array] } },
  provider_configs: { test: { name: 'test' } },
  managed_resources: {
    'test_resource.test': {
      mode: 'managed',
      type: 'test_resource',
      name: 'test',
      provider: [Object],
      pos: [Object]
    }
  },
  data_resources: {
    'data.test_data.test': {
      mode: 'data',
      type: 'test_data',
      name: 'test',
      provider: [Object],
      pos: [Object]
    }
  },
  module_calls: {
    storage: { name: 'storage', source: './modules/storage', pos: [Object] }
  }
}

Credits:

  • Fabian Ponce FabianPonce for recommending terraform-config-inspect

About

Node.js HCL parser for Terraform modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 71.1%
  • JavaScript 23.6%
  • HCL 5.3%