Using gopherjs to transpile Hashicorp's HCL into javascript.
Inspired by anhldbk/hcl-parser
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