Skip to content
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

Atlantis doesn't detect terraform version #1747

Closed
micborens opened this issue Aug 9, 2021 · 10 comments · Fixed by #1776
Closed

Atlantis doesn't detect terraform version #1747

micborens opened this issue Aug 9, 2021 · 10 comments · Fixed by #1776
Labels
bug Something isn't working

Comments

@micborens
Copy link

micborens commented Aug 9, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

Hello i'm facing an issue with Atlantis. I have different project which are running in terraform 0.15 or 1.0.
But atlantis doesn't detect properly the required_version specified in .tf file

terraform {
  required_providers {
...
  }
  required_version = "~> 0.15"
}

My atlantis.yaml

version: 3
projects:
  - name: project_name_1
    dir: <dir_project_name_1>
    workspace: <workspace xx>
    workflow: myworkflow
    autoplan:
      when_modified: [
          "*.tf",
          "vars/**.tfvars"
      ]
  - name: project_name_2
    dir: <dir_project_name_2>
    workspace: <workspace xx>
    workflow: myworkflow
    autoplan:
      when_modified: [
          "*.tf",
          "helm_values/**.yaml",
          "vars/**.tfvars"
      ]
workflows:
  myworkflow:
    plan:
      steps:
        - init
        - plan:
            extra_args: ["-var-file", "<path_to_my_tfvars>"]

project_name_1 is using terrafom 0.15
project_name_2 is using terraform 1.0

Reproduction Steps

Logs

Provide log files from Atlantis server

running "/usr/local/bin/terraform init -input=false -no-color" in "/......": exit status 1
Initializing modules...
...

Error: Unsupported Terraform Core version

  on providers.tf line 24, in terraform:
  24:   required_version = "~> 0.15"

This configuration does not support Terraform version 1.0.1. 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.

I'm running Atlantis in v0.17.2
I didn't setup defaultTFVersion in the helm chart deployment because i have my required version in my terraform file.
I don't want to freeze the terraform version in the atlantis.yaml to continue to be dynamic with my required_version.

I tested to freeze completly the terraform version (required_version = "0.15.5") and it works. BUT i don't want to waste time to update patch version of terraform.

Is there a feature request to detect terraform version like tfswitch tool is doing?

If you can help me. 🙏

@micborens micborens added the bug Something isn't working label Aug 9, 2021
@xavipanda
Copy link
Contributor

hmm... have u considered having workflow13 workflow14 workflow15... etc ? As you say you don't want to pin on the modules itself, but i guess its quite a good practice that you pin latest gen-version to the workflow ? :)

@fblgit
Copy link
Contributor

fblgit commented Aug 28, 2021

got a PR that should fix the issue @micborens feel free to try please :)

@grimm26
Copy link
Contributor

grimm26 commented Aug 29, 2021

https://www.runatlantis.io/docs/terraform-versions.html#via-terraform-config Yes you have to set the exact version of terraform that you want if you want the terraform config block to set the terraform version used by atlantis. Considering the changes the breaking changes that have come in tiny releases (major.minor.tiny) of terraform, it's not really a waste of time to specify the exact version you want to use.

This specific example isn't really a good one anyway because v0.15.5 is the last ever version of v0.15.x and v1.0.0 is essentially the same as v0.15.5. So if you have a project using 0.15, it can switch to 1.0 without any changes.

@micborens
Copy link
Author

@fblgit Awesome, i will test your branch with my use. thx 🙏
@grimm26 the use case here to don't be block my patch version and take advantage of terraform updates made by hashicorp in real time.

@romeuhcf
Copy link

romeuhcf commented Dec 3, 2021

The main blocker of having to use different workflows per project are:

  • if you configure one project directory, you'll need to configure all of them (Allow supplying wildcard for dir #686)
  • having dozens of project dirs on the same repo and more coming every other day.

@jamengual
Copy link
Contributor

is this still an issue with v0.19.8?

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label Aug 26, 2022
@pszypowicz
Copy link

Yeap, that's still the case.

It's according to the documentation, that only 'exact' version is matched. But it be awesome to do it automatically.

@github-actions github-actions bot added the Stale label Oct 28, 2022
@nitrocode nitrocode removed waiting-on-response Waiting for a response from the user Stale labels Nov 19, 2022
@nitrocode
Copy link
Member

I believe this is a duplicate of #1217. Let's thread the conversation there.

I'll close for now unless anyone disagrees.

@kvendingoldo
Copy link

btw. you can also use tenv that support Terraform as well as OpenTofu (and Terragrunt :) ) in one tool. It allow you to simplify version management and can do much more, than tfswitch.

@ricardosilva86
Copy link

Atlantis support this via terraform_version, you shouldn't use any further tool to accomplish this. Check the documentation for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants