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

--default-tf-version does not set terraform version to use #910

Closed
grimm26 opened this issue Jan 23, 2020 · 6 comments
Closed

--default-tf-version does not set terraform version to use #910

grimm26 opened this issue Jan 23, 2020 · 6 comments
Labels
question Further information is requested waiting-on-response Waiting for a response from the user

Comments

@grimm26
Copy link
Contributor

grimm26 commented Jan 23, 2020

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.

@lkysow
Copy link
Member

lkysow commented Jan 23, 2020

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 #639)

@lkysow
Copy link
Member

lkysow commented Jan 23, 2020

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

@lkysow lkysow added question Further information is requested waiting-on-response Waiting for a response from the user labels Jan 23, 2020
@grimm26
Copy link
Contributor Author

grimm26 commented Jan 23, 2020

PR created. #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.

@lkysow
Copy link
Member

lkysow commented Jan 23, 2020

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>'

@grimm26
Copy link
Contributor Author

grimm26 commented Jan 24, 2020

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

@grimm26 grimm26 closed this as completed Jan 24, 2020
@llamahunter
Copy link
Contributor

llamahunter commented Sep 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

3 participants