amplify-education / python-hcl2

MIT License
238 stars 52 forks source link

lark.exceptions.UnexpectedToken: Unexpected token Token(RPAR, ')') #14

Closed schosterbarak closed 4 years ago

schosterbarak commented 4 years ago

this exception happens for parsing a file with file(x) function like this one: https://www.terraform.io/docs/configuration/functions/file.html

schosterbarak commented 4 years ago

hey @aoskotsky-amplify any ideas how can i workaround this one?

aoskotsky-amplify commented 4 years ago

What value are you putting in as the argument to file()?

schosterbarak commented 4 years ago

path to a yaml file something like: file("${path.module}/hello.yaml")

aoskotsky-amplify commented 4 years ago

Can you add an example hcl2 file thats failing? I tried adding file("${path.module}/hello.yaml") in one of mine and i'm not getting that error

schosterbarak commented 4 years ago

Getting similar parsing error for:

resource "aws_security_group" "test" {
  vpc_id = module.dev_vpc.vpc_id
  ingress {
    protocol    = "tcp"
    from_port   = 443
    to_port     = 443
    cidr_blocks = [local.vpc.config.vpc_cidr, local.vpc.config.lnk_cidr]
  }
  ingress {
    protocol    = "tcp"
    from_port   = 80
    to_port     = 80
    cidr_blocks = [local.vpc.config.vpc_cidr, local.vpc.config.lnk_cidr]
  }
  ingress {
    protocol    = "tcp"
    from_port   = 22
    to_port     = 22
    cidr_blocks = [local.vpc.config.vpc_cidr, local.vpc.config.lnk_cidr]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
  tags  = merge(local.tags_default, {
    Name: "${local.vpc.config.vpc_nickname} test"
  })
}
schosterbarak commented 4 years ago

i think it's the ':'

aoskotsky-amplify commented 4 years ago

I don't think you are allowed to use : in hcl objects. It should be Name = "${local.vpc.config.vpc_nickname} test". Is that config actually working in Terraform?

m-wynn commented 4 years ago

I believe this is a Terraform 0.11 vs Terraform 0.12 issue. (See https://www.terraform.io/upgrade-guides/0-12.html#attributes-vs-blocks)

The 0.11 syntax guide describes a map using colons, while 0.12 only has maps with equals signs.

aoskotsky-amplify commented 4 years ago

Closing this issue since Terraform 0.11 syntax isn't supported by hcl2. Feel free to reopen this issue if it happens in your Terraform 0.12 configs