thazelart / terraform-validator

A norms and conventions validator for Terraform
Apache License 2.0
79 stars 9 forks source link

Hcl2 error in provider.tf #42

Closed marionbrioche closed 4 years ago

marionbrioche commented 4 years ago

Hi! I have an "assume_role" block in my provider.tf

provider "google" {
  version = "foo"

  assume_role {
    role_arn = "role"
  }
}

and I ran in this error:

2019/11/15 15:24:23 testdata/ok_default_config/providers.tf:5,3-14: Unexpected "assume_role" block; Blocks are not allowed here.

It seems that hcl2 libs are giving an error for a valid terraform format. Also the hcl2 repo is archived.

Are you aware of this issue?

thazelart commented 4 years ago

Hi Marion !

Indeed hcl2 is now archived thanks for the information, I didn't notice !

For your issue, terraform-validator is not supposed to extract that block (yet ?). I have to make some further tests so that I can fix it.

What is your final need ? Juste perform terrform-validator as it is right now ? Or do you want to add a new kind of test for your assume_role block ?

thazelart commented 4 years ago

Well, I compared google and aws provider's configuration pages. And I found that assume_role is an aws specific block which could explain your issue.

BUT, I have the same issue when I create an aws provider .. so I still have to investigate further.

marionbrioche commented 4 years ago

My final need is to run the terraform-validator without an error. Currently, we need to comment the block out to be able to run the command without error. Having the option to ensure the block is there would be useful but it's not a priority :smiley: Also, if you're looking for support I would be happy to help!

thazelart commented 4 years ago

Thanks Marion,

I managed to fix the bug during lunch break, the PR is now created (#44), test are running. Once everything is ok on that side I'll create a new release :smiley:

About your proposal, feel free to propose improvement, issue, etc. Everyone is welcome here !

About the new feature it could be a good idea for the future, even though #38 is higher priority in my opinion.

thazelart commented 4 years ago

Release 3.1.1 is out !

Change your release version in your CI or use 3.x or 3.1.x version If you want to be updated automatically next time 😉

marionbrioche commented 4 years ago

It works perfectly fine now! I will play with the tool some more and see about improvements

thazelart commented 4 years ago

Great, feel free !