virtuald/pyhcl

hcl.load throwing error in below code

niarora1406 opened this issue · 2 comments

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

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