Atlantis: --default-tf-version does not set terraform version to use

Created on 23 Jan 2020  路  6Comments  路  Source: runatlantis/atlantis

I'm running atlantis container version 0.11.1 which has terraform 0.12.19 installed. I am setting ATLANTIS_DEFAULT_TF_VERSION to v0.12.20. I see in the log that it does, in fact, download 0.12.20 but it does not seem to use it. State files written from atlantis applies still show 0.12.19 as the terraform version used.

Now, I do use the terragrunt workflow as described here, but terragrunt should just use the terraform that is in the PATH.

question waiting-on-response

All 6 comments

Hi Mark, so the terraform version downloaded by the --default-tf-version flag actually lands in ~/.atlantis/bin/terraform0.12.20. If you're using a custom workflow, you can run this binary via

- run: terraform$ATLANTIS_TERRAFORM_VERSION plan

Now when it comes to terragrunt, it sounds like you can set a TERRAGRUNT_TFPATH environment variable. So to put it all together I think it should look like:

- env:
    name: TERRAGRUNT_TFPATH
    command: echo terraform$ATLANTIS_TERRAFORM_VERSION
- run: terragrunt ...

(related to https://github.com/runatlantis/atlantis/issues/639)

if that works, I'd love it if you could submit a PR to update the docs.

PR created. https://github.com/runatlantis/atlantis/pull/911
I tested it out and it seems to work fine, but I am going back to doing a custom container image build with the version of terraform that I want added in the normal spot. I need to build a custom image anyway to add terragrunt (and tflint) and it will be a PITA if I need to change all of the custom tooling that I have added in my workflow to use terraform${ATLANTIS_TERRAFORM_VERSION} instead of just terraform.

Thanks for the PR. Yeah ideally we'd execute custom run steps with it somehow set that terraform is the version specified. Maybe we can just change the command to

bash -c 'terraform() { ~/.atlantis/bin/terraform$ATLANTIS_TERRAFORM_VERSION "$@"; } && <your command>'

closing since this was at base a documentation issue and that has been updated.

This is still not clear in the documentation here https://www.runatlantis.io/docs/terraform-versions.html#terraform-versions

Was this page helpful?
0 / 5 - 0 ratings

Related issues

majormoses picture majormoses  路  3Comments

tlkamp picture tlkamp  路  5Comments

lkysow picture lkysow  路  6Comments

richstokes picture richstokes  路  3Comments

ojacobson picture ojacobson  路  5Comments