Skip to content

terraform_required_version: false positive with multiple terraform blocks #1451

@bendrucker

Description

@bendrucker

Introduction

When multiple terraform blocks are defined, TFLint is unable to detect that required_version has been set, resulting in a warning for valid configuration. This is a regression in 0.39.0.

Expected Behavior

No reported issues.

Actual behavior

1 issue(s) found:

Warning: terraform "required_version" attribute is required (terraform_required_version)

  on  line 0:
   (source code not available)

Steps to Reproduce

terraform {
  required_version = ">= 1, < 2"
}

terraform {
  cloud {
    organization = "my-org"

    workspaces {
      name = "my-ws"
    }
  }
}
tflint --enable-rule terraform_required_version

Additional Context

$ tflint -v
TFLint version 0.39.0
$ terraform -v
Terraform v1.2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions