Using Atlantis with OpenTofu

Thursday, April 4, 2024

With Terraform moving from Open Source to the much more restrictive BSL I decided to move away from using it both personally and professionally. Luckily I am in a position to make these decisions and after a short (and painful) stint with Pulumi, I’ve decided to move forward using OpenTofu . At this point OpenTofu is a drop-in replacement for Terraform, being a fork of it. One question that was left open was whether Atlantis would work with OpenTofu or not. Well, the answer is yes, and here is how I got it working.

This is going to presuppose that you are deploying Atlantis with Helm on Kubernetes. If you aren’t than change the instructions as needed.

It’s actually a pretty painless process. First in your values.yaml file for Atlantis add the following which will download and install OpenTofu:

  enabled: true
  image: alpine:latest
  imagePullPolicy: IfNotPresent
  # sharedDir is set as env var INIT_SHARED_DIR
  sharedDir: /plugins
  workDir: /tmp
  sizeLimit: 250Mi
  script: |
    set -eoux pipefail

    # OpenTofu
    unzip tofu_${TF_VERSION}
    mv tofu ${INIT_SHARED_DIR}
    chmod 755 "${TF_FILE}"
    tofu -v

Next modify your atlantis.yaml in the Terraform/Tofu repository to call tofu:

version: 3
  - name: some-project
    dir: .
    workspace: default
    workflow: some-project

      - run: rm -rf .terraform
      - run: tofu init -reconfigure -backend-config environments/production/init.tfvars
      - run: tofu plan -var-file environments/production/apply.tfvars
      - run: rm -rf .terraform
      - run: tofu init -reconfigure -backend-config environments/production/init.tfvars
      - run: tofu apply -auto-approve -var-file environments/production/apply.tfvars

And that’s it! Tofu runs perfectly as a drop-in replacement for Terraform.


Helm Chart for Cloudflare Tunnels

Borgbackup, Private SSH Keys, and MacOS