-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Terraform state commands ignores required_version #28025
Description
I found a nasty issue, where terraform ignores required_version field in the configuration. I switch between two environments with different versions of the terraform and I rely on the required_version field to take care of things.
I was trying to move a resource within the state to the module but unfortunately I used the different tf binary (with newer version) than I wanted to. Running the following command was successful, even though it shouldn't be:
terraform state mv [src] [dst]
Result of this is updated state.
Terraform Version
Terraform v0.14.7
Terraform Configuration Files
terraform {
required_version = "~> 0.12.20"
backend "gcs" {
...
}
}
Debug Output
Crash Output
Expected Behavior
Running the terraform state commands verifies the version constrain defined in the required_version field and if the constrain is not fulfilled, terraform prints out the same error message as in the other commands:
This configuration does not support Terraform version 0.14.7. To proceed,
either choose another supported Terraform version or update this version
constraint. Version constraints are normally set for good reason, so updating
the constraint may lead to other errors or unexpected behavior.
Actual Behavior
Command is successful when version constraint is not fulfilled and the state is upgraded to the newer version.
Steps to Reproduce
Mentioned above.