-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform reports incompatible version pointing at the last "terraform.required_version" line, even if it is a previous line which is the unmatched constraint #25833
Comments
I am unable to reproduce this issue, and can't see how it could be happening. Can you provide a small reproduction configuration which demonstrates the problem, along with a list of commands you are running? Attempted reproductionThis works as expected:
|
Hi Alisdair, thanks for your attempt to reproduce my observation. Some background info: I'm using shell scripts #!/usr/bin/env bash
COMMON_FOLDER="$(cd "$( dirname "${BASH_SOURCE[0]}" )/../../common/" && pwd )"
echo "Executing 'terraform $@ $COMMON_FOLDER':"
terraform "$@" "$COMMON_FOLDER" Launching
For execution of #!/usr/bin/env bash
./terraform-common.sh init "$@" -backend-config ./terraform.gcs-backend.config Launching
Hint: My workspace misses something like |
Unfortunately I still can't reproduce the issue you're seeing. The shell scripts alone don't seem to explain what could be causing this, and without your full configuration I can't understand what is happening on your system. Can you provide a small reproduction test case? One way to do that would be as a pull request to our issue reproductions repository, but if it's easier to respond here that would be great too! |
Pretty sure I'm hitting somethign similar. Constraint: terraform {
required_version = ">= 0.12"
} I'm using the Docker container: Output of an attempt to plan: Error: Unsupported Terraform Core version
--
|
| on versions.tf line 2, in terraform:
| 2: required_version = ">= 0.12"
|
| This configuration does not support Terraform version 0.13.0. 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. |
So, seems I've fixed it myself without knowing which step exactly makes Terraform happy 😄
So here it stumbles over the same issue, but on another location in my Terraform code.
Fine! Now let's issue the
OK, so let's run
Final step: Rerun
Bingo! 👍 |
@jufemaiz That looks similar, yes. I still can't see how it's possible and can't reproduce the issue. I believe the problem must be an error message pointing at the wrong position in the configuration, but that's just a guess. Are you able to pare down your configuration to a minimal reproduction case? Doing so would allow us to fix this misleading error message. |
OK, what do you mean by |
@alisdair let me see what I can do. It's not an easy one – initial state needs to be set up, then use the new image and hope it fails. terraform {
required_version = "~> 0.12.20"
backend "local" {
path = "terraform.tfstate"
}
}
provider "aws" {
region = "ap-southeast-2"
version = "~> 2.48"
}
terraform {
required_version = ">= 0.12"
}
resource "aws_sns_topic" "test_topic" {
name = "test_topic"
} ---
version: '3.7'
services:
terraform:
image: hashicorp/terraform:light
command: ['terraform', 'apply']
entrypoint: ''
environment:
AWS_DEFAULT_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID:
AWS_SECRET_ACCESS_KEY:
AWS_SESSION_TOKEN:
# SSH Support
SSH_AUTH_SOCK: /ssh-agent
tty: true
volumes:
- ./:/app/
- ${HOME}/.terraformrc:/root/.terraformrc:ro
- ${HOME}/.ssh/known_hosts:/root/.ssh/known_hosts:ro
- ${SSH_AUTH_SOCK}:/ssh-agent
working_dir: '/app' The problem lies with: required_version = "~> 0.12.20" is causing the issue but isn't being indicated in the error message (hence the reference to |
@jufemaiz Thank you, this was very helpful! I have an even smaller reproduction now: terraform {
required_version = "~> 0.12.20"
}
terraform {
required_version = ">= 0.12"
} This causes $ terraform init
Error: Unsupported Terraform Core version
on main.tf line 6, in terraform:
6: required_version = ">= 0.12"
This configuration does not support Terraform version 0.13.0. 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. @dcmoeller We now have a simple reproduction of the issue, and I'm glad you were able to get your configuration working too. Thanks for the bug report! |
There's an explanation of the source of the bug and a fix in #25898. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
After upgrading to Terraform 0.13.0 my first invocation fails with
Here is a snippet from mentioned
google-cloud-platform.tf
file:OK, let's try it with
required_version = "~> 0.13.0"
:Weird.
Surprisingly all the following yields equivalent negative results:
required_version = ">= 0.13.0"
required_version = ">= 0.12.0"
required_version = "> 0.12.0"
Am I missing something, or is this a bug?
Regards
Terraform Version
Debug Output
The same output as reported above.
Additional Context
The text was updated successfully, but these errors were encountered: