terraform version: Usage & Common CI Errors
Confirm exactly which Terraform and provider versions your job is running.
terraform version prints the Terraform CLI version, the platform, and the versions of installed providers - the first thing to check when CI behaves differently from your laptop.
What it does
terraform version reports the CLI version and, if a directory has been initialized, the provider versions in use. It also tells you whether a newer release is available. With -json it emits structured data for pinning checks in CI.
Common usage
# Print CLI + provider versions
terraform version
# Machine-readable for CI assertions
terraform version -json | jq -r '.terraform_version'Common error in CI: required_version constraint not met
A plan/init aborts with "Error: Unsupported Terraform Core version ... this configuration does not support Terraform version X; the required_version is \">= 1.6.0\"". The runner has a different CLI than the config demands. Fix: pin the CLI in CI (e.g. hashicorp/setup-terraform with terraform_version, or tfenv) to satisfy the required_version block in terraform {}. Run terraform version early in the job to fail fast with a clear message.
Key options
| Option | Purpose |
|---|---|
| -json | Emit version info as JSON |