required-version
What it does
Section titled “What it does”Reports a module none of whose terraform blocks sets required_version, on the terraform block, or on the start of main.tf when the module has no such block. Override files do not count.
Why it matters
Section titled “Why it matters”Terraform language features and the state format change between versions, and a state file written by a newer version cannot be used by an older one. A constraint makes an incompatible version fail at the start with a clear message instead of in the middle of an apply.
To fix, set required_version in a terraform block.
Example
Section titled “Example”terraform { backend "s3" {} required_providers { aws = { source = "hashicorp/aws", version = "~> 5" }...Configuration
Section titled “Configuration”hcl: lint: rules: required-version: warn # off (default), warn, errorEnabled by the presets: hcl/tflint-recommended.
Suppress one line with sudsy-disable-next-line required-version in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| tflint | terraform_required_version |
partial | A module with no terraform block at all is not reported (it needs the other files of the module). |