amplify-education / python-hcl2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unexpected IDENTIFIER; expected PERIOD

ayushkothari27 opened this issue · comments

Error running this block -

resource "aws_ebs_volume" "changeme_ebs_volume_snapshot" {
availability_zone = data.aws_availability_zones.changeme_az_list_ebs_snapshot.names[0]
size = 10
type = "standard"
encrypted = false
tags = {
Name = "changeme_ebs_volume_tag"
}
}

Error trace -
ayush.kothari@MacBook-Pro-rpc Desktop % python3 parser.py
Traceback (most recent call last):
File "/Users/ayush.kothari/Desktop/parser.py", line 4, in
obj = hcl.load(fp)
File "/Users/ayush.kothari/Library/Python/3.9/lib/python/site-packages/hcl/api.py", line 62, in load
return loads(fp.read(), export_comments=export_comments)
File "/Users/ayush.kothari/Library/Python/3.9/lib/python/site-packages/hcl/api.py", line 81, in loads
return HclParser().parse(s, export_comments=export_comments)
File "/Users/ayush.kothari/Library/Python/3.9/lib/python/site-packages/hcl/parser.py", line 642, in parse
return self.yacc.parse(
File "/Users/ayush.kothari/Library/Python/3.9/lib/python/site-packages/hcl/ply/yacc.py", line 503, in parse
tok = self.errorfunc(errtoken)
File "/Users/ayush.kothari/Library/Python/3.9/lib/python/site-packages/hcl/parser.py", line 634, in p_error
raise ValueError(msg)
ValueError: Line 26, column 532: unexpected IDENTIFIER; expected PERIOD

Works for me: May be you are on the old version of hcl2 lib?

resource "aws_ebs_volume" "changeme_ebs_volume_snapshot" {
availability_zone = data.aws_availability_zones.changeme_az_list_ebs_snapshot.names[0]
size = 10
type = "standard"
encrypted = false
tags = {
Name = "changeme_ebs_volume_tag"
}
}
{
  "resource": [
    {
      "aws_ebs_volume": {
        "changeme_ebs_volume_snapshot": {
          "availability_zone": "${data.aws_availability_zones.changeme_az_list_ebs_snapshot.names[0]}",
          "size": 10,
          "type": "standard",
          "encrypted": false,
          "tags": {
            "Name": "changeme_ebs_volume_tag"
          }
        }
      }
    }
  ]
}

@sahilsk What version are you using