Blocks of type "required_providers" are not expected here
skyzyx opened this issue · 6 comments
Firstly, this is a great tool. I use it constantly for a large number of Terraform modules I maintain. Thank you!
In my versions.tf
file, I have a block which looks like this:
# https://www.terraform.io/docs/configuration/terraform.html
terraform {
required_version = ">= 0.12"
required_providers {
aws = "~> 2.67"
newrelic = "~> 1.19"
}
}
A truncated version of my .terraform-validator.yaml
file looks like this:
layers:
default:
files:
versions.tf:
mandatory: true
authorized_blocks:
- required_providers # only added this after receiving the error message; it didn't help
- terraform
When I run the tool, I get this message:
$ terraform-validator .
2020/07/03 01:07:04 versions.tf:5,3-21: Unsupported block type; Blocks of type "required_providers" are not expected here.
The required_providers
sub-block of a terraform
block is documented here: https://www.terraform.io/docs/configuration/terraform.html#specifying-required-provider-versions
How do I get terraform-validator
to allow/enforce this block without throwing an error?
Just a note that having documentation like this would make it easier to contribute and submit a PR.
Seems like the parser simply doesn't know about newly added parameters.
terraform-validator/internal/hcl/hcl_parse.go
Line 194 in 1e5c985
https://github.com/thazelart/terraform-validator/blob/master/internal/hcl/hcl_parse_hcl_types.go#L39
And may be in a few more places
👍🏻 Love the production, unfortunately now all my modules are showing red in validation... 😭
Hey there,
thank you guys posting this issue and working on it.
I was quite busy the last few months ...
@dvishniakov is right, tfv is not yet aware of the new parameters ... I'll try to manage it as soon as possible.
@skyzyx I can work on it too, that's a great idea.
About what you tried in your config file. This won't work as it's a sublock (inside terraform)
Thanks again, and as said previously, I'll try to manage this asap
Hey guys,
I'm still working on it, I should be able to push a fix tonight.
Here's how I'll manage the thing:
- from this issue I'll push a fix that will unlock you
- As soon as I have more time I'll propose a new feature to ensure that all required providers have a version (for this step I'll create another issue)
thank you for being so patient 😉
Hey guys, that's fixed now, please use release 3.1.2 (https://github.com/thazelart/terraform-validator/releases/tag/3.1.2)
That should work. If not, don't hesitate to comment here and reopen the issue