virtuald / pyhcl

HCL is a configuration language. pyhcl is a python parser for it.
Mozilla Public License 2.0
336 stars 60 forks source link

hcl.load throwing error in below code #73

Closed niarora1406 closed 4 years ago

niarora1406 commented 4 years ago

Terraform code in storage_Accounts.tf file :

resource "azurerm_storage_account" "PAN_FW_STG_AC" { name = join("",list("paloalto", substr(md5"${azurerm_resource_group.fw-e2-rg.name}+1", 0, 4))) resource_group_name = azurerm_resource_group.fw-e2-rg.name location = "eastus2" account_replication_type = "LRS" account_tier = "Standard" }

I don't see any error in my tf code as tf-plan and tf-apply works fine . i try to parse this code but it throws error :

import hcl

with open('storage-accounts.tf', 'r') as fp: obj = hcl.load(fp) print(obj)

Error:

ValueError: Line 7, column 315: unexpected LEFTPAREN; expected ASTERISK_PERIOD, RIGHTBRACKET, COMMA, RIGHTPAREN, ADD, MINUS, MULTIPLY, DIVIDE

virtuald commented 4 years ago

That looks like HCL2 to me, which as the readme states is not supported.

virtuald commented 4 years ago

You might try https://pypi.org/project/python-hcl2/