Skip to content

docs: Promote Terraform distribution agnosticism in Terragrunt example#6620

Open
lachlankidson wants to merge 3 commits into
runatlantis:mainfrom
lachlankidson:patch-1
Open

docs: Promote Terraform distribution agnosticism in Terragrunt example#6620
lachlankidson wants to merge 3 commits into
runatlantis:mainfrom
lachlankidson:patch-1

Conversation

@lachlankidson

@lachlankidson lachlankidson commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

what

Updates the terragrunt example documentation to be terraform distribution agnostic.
(i.e. no longer hardcode terraform or tofu).

why

This allows for Atlantis + terragrunt to manage repositories where there are both terraform and tofu projects present, e.g. an atlantis.yaml similar to:

projects:
  - dir: projects/a
    autoplan:
      when_modified: ["**/*.hcl", "**/*.tf"]
    terraform_distribution: terraform

  - dir: projects/b
    autoplan:
      when_modified: ["**/*.hcl", "**/*.tofu"]
    terraform_distribution: opentofu

tests

We're using this approach successfully in our own repositories.

references

Environment variables set here:

customEnvVars := map[string]string{
"ATLANTIS_TERRAFORM_DISTRIBUTION": tfDistribution.BinName(),
"ATLANTIS_TERRAFORM_VERSION": tfVersion.String(),

Resolves to either tofu or terraform, confirmed by tests:

func TestOpenTofuBinName(t *testing.T) {
d := terraform.NewDistributionOpenTofu()
Equals(t, d.BinName(), "tofu")
}

func TestTerraformBinName(t *testing.T) {
d := terraform.NewDistributionTerraform()
Equals(t, d.BinName(), "terraform")
}

DEFAULT_TERRAFORM_VERSION removed as it refers to terraform specifically, the tofu equivalent is DEFAULT_OPENTOFU_VERSION:

atlantis/Dockerfile

Lines 9 to 11 in ac39085

ARG DEFAULT_TERRAFORM_VERSION=1.14.9
# renovate: datasource=github-releases depName=opentofu/opentofu versioning=hashicorp
ARG DEFAULT_OPENTOFU_VERSION=1.12.3

which is not required as both tofu and terraform's default versions are symlinked:

ln -s "${COMMAND_DIR}/${DEFAULT_VERSION}/${COMMAND_NAME}" "${COMMAND_DIR}/${COMMAND_NAME}"

ATLANTIS_TERRAFORM_VERSION can either be specified by projects/pins or derived if not present:

atlantis/cmd/server.go

Lines 490 to 493 in ac39085

DefaultTFVersionFlag: {
description: "Terraform version to default to (ex. v0.12.0). Will download if not yet on disk." +
" If not set, Atlantis uses the terraform binary in its PATH.",
},

Signed-off-by: Lachlan Kidson <lachlankidson@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 2, 2026 14:36
@dosubot dosubot Bot added the docs Documentation label Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Terragrunt custom workflow documentation to avoid hardcoding terraform/tofu, enabling mixed Terraform/OpenTofu repositories to work cleanly with Atlantis’ per-project distribution selection.

Changes:

  • Replace terraform${...} hardcoding in Terragrunt TG_TF_PATH examples with ${ATLANTIS_TERRAFORM_DISTRIBUTION}${ATLANTIS_TERRAFORM_VERSION}.
  • Remove usage of DEFAULT_TERRAFORM_VERSION in the example workflow.

Comment thread runatlantis.io/docs/custom-workflows.md Outdated
- env:
name: TG_TF_PATH
command: 'echo "terraform${DEFAULT_TERRAFORM_VERSION}"'
command: 'echo "${ATLANTIS_TERRAFORM_DISTRIBUTION}"'

@lachlankidson lachlankidson Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See DEFAULT_TERRAFORM_VERSION / DEFAULT_OPENTOFU_VERSION notes in references section of the PR description. This suggestion might be a good one, but its a divergence from the previous behaviour, similarly we'd want to make the same change to L334.

Signed-off-by: Lachlan Kidson <lachlankidson@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants