atlantis: Autodownloading Terraform 1.8.2 breaks Atlantis entirely

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

Hashicorp just released Terraform v1.8.2 with a breaking change to the release, by including a license file with the packaged version:

NOTE:

Starting with this release, we are including a copy of our license file in all packaged versions of our releases, such as the release .zip files. If you are consuming these files directly and would prefer to extract the one terraform file instead of extracting everything, you need to add an extra argument specifying the file to extract, like this:

unzip terraform_1.8.2_linux_amd64.zip terraform

Reproduction Steps

atlantis plan or atlantis apply with an unpinned terraform version

Logs

downloading terraform version 1.8.2 at "https://releases.hashicorp.com/terraform/1.8.2/terraform_1.8.2_linux_amd64.zip?checksum=file:https://releases.hashicorp.com/terraform/1.8.2/terraform_1.8.2_SHA256SUMS": expected a single file: /tmp/getter1796155136/archive

Environment details

Additional Context

See https://github.com/runatlantis/atlantis/issues/4472#issuecomment-2075001953

👋🏻 TF Core maintainer here, who also happened to cut the release with the change that has impacted you. As mentioned above we did call this out in the changelog but broadly speaking did not anticipate this to be a breaking change that would warrant heads up.

go-getter, which is a library Atlantis appears to be using to install Terraform currently was not designed for this use case, or even broadly interacting with releases.hashicorp.com and we do not intend to make changes in that library to accommodate that use case.

On a more positive note, we do maintain a library that can aid with installation of HashiCorp products, including Terraform - hc-install and we use it ourselves in a number of places. Atlantis would be welcomed to use it as well. That library does not make assumptions about the archive having just one file. Our enterprise packages (although not relevant for Terraform here specifically) already have multiple files and the API accounts for this too, where the consumers specify a path where the license should be placed.

For Terraform CE, the API would let you specify Dir as a path to the directory where the archive gets unpacked, including terraform binary and the license file. What consumers decide to do with those files after the installation would be up to them. The API does not currently make any further assumptions about those files for non-Enterprise versions.

I appreciate this may not be as simple as a drop-in replacement but I hope the API along with examples and documentation is self-explanatory. If you have any questions about it or if it doesn’t work for you we’d certainly like to hear it in our issue tracker and be more open to making some changes there (as opposed in go-getter).

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 193
  • Comments: 24 (9 by maintainers)

Most upvoted comments

One quick and easy solution would be to softlink terraform1.8.2 to terraform1.8.1 for now.

that’s one horrible hack

I’m not doing release myself, but the fix was already cherry picked to release-0.27, so I would expect a new atlantis release soon.

If you have 1000s of root dirs, without having to modify anything, one quick and dirty solution would be to softlink terraform1.8.2 to terraform1.8.1 for now.

This is what I did to unblock devs for now

ln -sf /atlantis/bin/terraform1.8.1 /atlantis/bin/terraform1.8.2
repos:
  - id: /.*/
    # temp fix for https://github.com/runatlantis/atlantis/issues/4471
    pre_workflow_hooks:
      - description: Temporary hack for post-terraform 1.8.1
        run: |
          ln -sf /atlantis/bin/terraform1.8.1 /atlantis/bin/terraform1.8.2
          # ...

This is a hack like Fernando mentioned. It’s meant as a stop-gap for a better solution.

here is slightly cleaner method than @nitrocode 's method(overwriting another version.) this is using init config for downloading the 1.8.2 binary through and stores in plugins dir, to use the terraform1.8.2 command as the actual version. Of course, this method is not a fundamental solution either, but it will prevent the problem of unintentionally confusing version 1.8.1 with 1.8.2 in the future.

here is my helm values examples

i hops this will helps who struggles to get work with cleaner methods

  initConfig:
    # -- Install providers/plugins into a path shared with the Atlantis pod.
    enabled: true
    image: alpine:latest
    imagePullPolicy: IfNotPresent
    # -- SharedDir is set as env var INIT_SHARED_DIR.
    sharedDir: /plugins
    workDir: /tmp
    # -- Size for the shared volume.
    sizeLimit: 100Mi
    # -- Security context for the container.
    securityContext: {}
    # -- Script to run on the init container.
    # @default -- Check values.yaml.
    script: |
      #!/bin/sh

      wget https://releases.hashicorp.com/terraform/1.8.2/terraform_1.8.2_linux_amd64.zip
      unzip terraform_1.8.2_linux_amd64.zip terraform
      cp /tmp/terraform ${INIT_SHARED_DIR}/terraform1.8.2
      ls -la ${INIT_SHARED_DIR}

Hi there

As a workaround, we setting on the variables environment the follow value

ATLANTIS_DEFAULT_TF_VERSION=1.8.1
ATLANTIS_TF_DOWNLOAD=false

My team’s workaround as suggested by https://github.com/runatlantis/atlantis/issues/4472#issuecomment-2074701092 is pinning the required version in our main.tf. Annoying if you have large project environments. Will use this until this is fixed. Here is the example:

Previous main.tf:

terraform {
  required_version = ">= 1.1.0, < 2.0.0"
  ...

Pinned main.tf:

terraform {
  required_version = "1.8.1"

I’m not on the latest version of atlantis helm release but it looks like you might be able to leverage defaultTFVersion in the values.yaml until this is sorted: https://artifacthub.io/packages/helm/atlantis/atlantis?modal=values&path=defaultTFVersion

defaultTFVersion: "1.8.1"

Closing this as the original issue has been mitigated in #4474, back ported into the 0.27 release branch, and released in 0.27.3. For discussion of a long-term fix, see #4494 and #4483

I have also proposed a small fix. Tested here with testdrive and worked fine.

#4478