Request: Support Compatibility with OpenTofu + `tenv`
rdhar opened this issue · comments
Is your feature request related to a problem
N/a.
Describe the solution you'd like
With the launch of OpenTofu fork, I'd like to support OpenTofu as a first-class IaC provisioning tool, just like Hashicorp's Terraform.
Describe alternatives you've considered
While we await (pre-)releases to become available, a serviceable workaround has been shared by @zimeg (from Slack) to download, install and initialize OpenTofu CLI in 3 GitHub Actions steps.
- name: Download the tofu source
uses: actions/checkout@v4
with:
repository: opentofu/opentofu
path: opentofu
- name: Install tofu tooling
uses: actions/setup-go@v4
with:
go-version-file: opentofu/go.mod
cache-dependency-path: opentofu/go.sum
- name: Prepare the tofu command
working-directory: opentofu
run: |
go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/tofu .
echo $(pwd)/bin >> $GITHUB_PATH
Additional context
Issue opentofu/opentofu#556 has been raised in order to deliver a more "drop-in replacement"-able equivalent to hashicorp/setup-terraform.
Over the last month, OpenTofu has published opentofu/setup-opentofu to lower the barrier to entry for implementing tofu
as part of the CI/CD pipelines.
While we deliver first-class support with OpenTofu, we must ensure backwards-compatibility with Hashicorp Terraform. As result, the decision for choosing between must be easily user-configurable.
btw. you can also integrate tenv that support Terraform as well as OpenTofu (and Terragrunt :) ) in one tool. It allow you to simplify version management.
Good call, @kvendingoldo! Despite using tenv
locally, I hadn't considered adding it here before and it's well worth implementing.
Also worth mentioning that, as of the latest v10 release, this Action no longer ships with setup-opentofu or setup-terraform, in order to reduce dependencies and enable the user to supply their own configuration directly.
As a result, I've opened a PR to add a functional demo using tenv
in a scenario which tests both terraform
and tofu
execution simultaneously. Aside, also opened a wee request to allow explicit/unambiguous human-friendly aliases for tenv
tool names.
Only remaining issue is PR output comment. More specifically, the aforementioned setup-opentofu/terraform Actions come with their own wrapper script which exposes stdout
, stderr
, and exitcode
automatically by default. These outputs are leveraged when creating PR comments like this. Is there a similar-ish equivalent for sourcing tenv
outputs?
I think that we can easily implement sourcing tenv
outputs. Can you open an issue for that, pls? We'll take a look as soon as it would be possible for the team.
Sure, @kvendingoldo, I've just gone ahead and opened that request -- though I worry it might be "deceptively simple".
The setup-opentofu/terraform Actions are... Actions. So it's easier for them to supply a wrapper script with custom outputs which are particularly suited for use in CI automation.
I'd be just as happy with workaround suggestions using bash/shell within CI context as well.