terraform_required_version
: fix regression with multiple blocks
#1452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a regression where multiple
terraform {}
blocks results in a false positive issue being emitted. https://github.com/terraform-linters/tflint/pull/1433/files#diff-0ec954b5c7913111444d96417f3325c4a2f5d91507770a89022bcbd4b05319cb, which rewrote chunks of theterraformrules
package to eliminate dependencies on Terraform internals, introduced this regression. The new code, which operates on the generic HCL structure rather than the parsed Terraform internal representation has a simple logic error:This processes every
terraform
block and emits and error ifrequired_version
is unset. Instead, the rule should process all the blocks and emit a single error if none has the attribute set.Fixes #1451