runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.68k stars 1.05k forks source link

Terraform version in atlantis.yaml is ignored #1598

Open LuigiClemente-Awin opened 3 years ago

LuigiClemente-Awin commented 3 years ago

I am having issues after upgrading my docker image to Atlantis 0.17.0. I am using an atlantis.yaml configuration to pin the terraform version for a specific project:

  - name: atlantis-test-dev
    dir: atlantis-test-se-dev
    terraform_version: 0.14.5
    autoplan:
      enabled: true
    workflow: atlantis-test-opa

In the custom workflow I check the tf version:

   atlantis-test-opa:
    plan:
      steps:
        - run: echo "### TERRAFORM VERSION"
        - run: terraform version 

I see that now the version set is ignored and it is using the default 0.15.1:

  ### TERRAFORM VERSION

Terraform v0.15.1
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.25.0
+ provider registry.terraform.io/hashicorp/random v3.0.1

This was working fine in 0.16.1. I reverted to Atlantis version 0.16.1 and the configured Terraform version is used:

### TERRAFORM VERSION

Terraform v0.14.5
+ provider registry.terraform.io/hashicorp/aws v3.25.0
+ provider registry.terraform.io/hashicorp/random v3.0.1

Thanks,

Luigi

dhaven commented 3 years ago

Hi,

As a workaround you could specify the full path to the terraform binary downloaded by atlantis. The following should work : /home/atlantis/.atlantis/bin/terraform${ATLANTIS_TERRAFORM_VERSION}

grimm26 commented 3 years ago

@LuigiClemente-Awin as @dhaven said, you have to append ${ATLANTIS_TERRAFORM_VERSION} to the terraform command. Atlantis does not change symlinks to what is the active terraform binary version, it just uses that environment variable. The only reason this may have "worked" for you in atlantis 0.16.1 is that 0.14.5 was the default terraform version then anyway.

fblgit commented 3 years ago

I guess that if u set the right terraform_version within the tf, and remove it from atlantis.yaml https://github.com/runatlantis/atlantis/pull/1776 this should fix your scenario.

howbazaar commented 1 year ago

https://www.runatlantis.io/docs/terraform-versions.html has a v prefix to the terraform version. Does that help?