Skip to content

Conversation

bendrucker
Copy link
Member

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 the terraformrules 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:

for _, block := range body.Blocks {
	if _, exists := block.Body.Attributes["required_version"]; !exists {

This processes every terraform block and emits and error if required_version is unset. Instead, the rule should process all the blocks and emit a single error if none has the attribute set.

Fixes #1451

@bendrucker bendrucker merged commit 10be233 into master Jul 27, 2022
@bendrucker bendrucker deleted the issues/1451 branch July 27, 2022 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

terraform_required_version: false positive with multiple terraform blocks
1 participant