Atlantis: Document that custom workflows don't use correct terraform version

Created on 22 May 2019  路  12Comments  路  Source: runatlantis/atlantis

If you use terraform in your custom workflow, ex

projects:
- dir: .
  terraform_version: v0.12.0
  workflow: custom

workflows:
  custom:
    plan:
      steps:
      - run: terraform init

Atlantis won't use the version of terraform specified via terraform_version. Instead it is just running sh -c "terraform init" so whatever binary is called terraform will be used. To use the correct version (for now) you need to actually specify the path to where Atlantis downloads it:

- run: /home/atlantis/.atlantis/bin/terraform0.12.0
docs

Most helpful comment

We faced this issue last week when updated to Atlantis v0.8.0, and solved it by executing the custom commands with the project-specific Terraform version like this:

- run: terraform$ATLANTIS_TERRAFORM_VERSION

All 12 comments

We faced this issue last week when updated to Atlantis v0.8.0, and solved it by executing the custom commands with the project-specific Terraform version like this:

- run: terraform$ATLANTIS_TERRAFORM_VERSION

@lkysow I think it might be a bit more annoying that having to specify the path where the version you want lives in your workflow.

If the version you request is not downloaded yet, it looks like it won't be available for the custom workflow.

Is there any way to force the download in the custom workflow ?

For the docker image, It also looks like newly downloaded binaries are added in /home/atlantis/.atlantis/bin/ which is not in PATH.
Meaning that depending on if you plan to use a downloaded binary or one available by default with the default docker image, you'd need to have some logic to find where the binary is. @nikovirtala 's solution wouldn't work for binaries downloaded by atlantis

We should add /home/atlantis/.atlantis/bin/ to the PATH before exec'ing.

Do you mean in the docker-entrypoint.sh file ? If yes, I'm happy submitting a PR for that.
For the other issue ( the binary not being downloaded ), do you want me to create another bug ?

I was thinking doing it in the actual run_step_runner because we shouldn't assume everyone's using our Docker image.

RE bug, yes that sounds good as another ticket.

RE bug, yes that sounds good as another ticket.

Was this ticket opened?

RE bug, yes that sounds good as another ticket.

Was this ticket opened?

it is now, sorry for the delay

@lkysow

I've been taking a quick look at the run_step_runner solution you were taking about , the issue I have is that we'd need to have access to the UserConfig.DataDir ( which is where it looks like the binaries are downloaded )

It doesn't look like run_step_runner has an easy access to that.

My implementation thoughts:

  • Add a method to TerraformClient BinDir() string that returns the bin dir
  • Add a new field to RunStepRunner called TerraformBinDir
  • In server/server.go, where RunStepRunner is constructed, set TerraformBinDir to terraformClient.BinDir()
  • now you can use this in the run step runner

That makes sense to me. Let me try to take a stab at this

Seems that projects listed in repository atlantis.yaml do not respect Terraform version stated in versions.tf.
Is that expected behaviour? For a time being I had to set TF version explicitly in atlantis.yaml to bypass that problem.

I use custom workflow, but without custom commands for plan/apply.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

younus2019 picture younus2019  路  4Comments

tlkamp picture tlkamp  路  5Comments

cheethoe picture cheethoe  路  4Comments

lkysow picture lkysow  路  4Comments

stephencoe picture stephencoe  路  5Comments