sikula / ruby-hcl

Ruby Parser for the Hashicorp Configuration Language
MIT License
14 stars 3 forks source link

Unable to parse heredoc #8

Open pschipitsch opened 8 years ago

pschipitsch commented 8 years ago

Parsing this file:

provider "aws" {
    region = "us-west-1"
}

resource "aws_iam_role" "consumer" {
  name               = "consumer"
  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF

  lifecycle {
    create_before_destroy = true
  }
}

results in this error:

HCLLexer::ScanError: can not match: '<<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF

  lifecycle {
    create_before_destroy = true
  }
}
'
    from /Users/pschipitsch/repos/ruby-hcl-upstream/lib/hcl/lexer.rb:110:in `_next_token'
    from /Users/pschipitsch/repos/ruby-hcl-upstream/lib/hcl/lexer.rb:50:in `next_token'
    from /Users/pschipitsch/repos/ruby-hcl-upstream/lib/hcl/lexer.rb:122:in `lex'
    from parse.y:144:in `parse'
    from (irb):2
    from /Users/pschipitsch/.rbenv/versions/2.2.2/bin/irb:11:in `<main>'
sikula commented 8 years ago

I believe, when I wrote this, the Hashicorp's original implementation did not support heredocs. My schedule has been busy recently and I haven't had time to work on this project too much. I am not entirely sure I would be able to add heredoc support, but I will work try to publish it as a gem in the next few days.