Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tools such as OpenTofu instead of Terraform #1554

Merged
merged 6 commits into from
Feb 28, 2024

Conversation

suzuki-shunsuke
Copy link
Owner

@suzuki-shunsuke suzuki-shunsuke commented Feb 27, 2024

Close #1203
Close #1551

Caution

We don't usually use OpenTofu and Terragrunt, so we haven't done only simple verification.

Overview

This pull request enables us to execute tools compatible with Terraform instead of Terraform.
tfaction executes Terraform commands such as terraform init, fmt, validate, plan, apply, and so on.
This pull request enables us to replace Terraform with other tools compatible with Terraform.
You can use tools such as OpenTofu and Terragrunt instead of Terraform.

How

You can specify a tool by the setting terraform_command in tfaction-root.yaml and tfaction.yaml.

tfaction-root.yaml

terraform_command: tofu # terragrunt
target_groups:
  - working_directory: aws/
    terraform_command: tofu # terragrunt

tfaction.yaml

terraform_command: tofu # terragrunt

Then the given command is executed instead of terraform.
For example, if terraform_command is tofu, commands such as tofu init, fmt, validate, plan, apply are executed instead of terraform.

💡 Combine OpenTofu and Terragrunt

You can also combine OpenTofu and Terragrunt.

  1. Set terraform_command to terragrunt
  2. Set the environment variable TERRAGRUNT_TFPATH to tofu

💡 Validate terraform_command

You can validate terraform_command in GitHub Actions Workflows.

      - uses: suzuki-shunsuke/tfaction/get-target-config@v1.2.0
        id: target-config

      - run: |
          echo "::error:: terraform_command is invalid"
          exit 1
        if: |
          ! contains(fromJSON('["terraform", "terragrunt", "tofu"]'), steps.target-config.outputs.terraform_command)

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Feb 27, 2024
@suzuki-shunsuke suzuki-shunsuke added this to the v1.2.0 milestone Feb 27, 2024
@suzuki-shunsuke suzuki-shunsuke marked this pull request as ready for review February 28, 2024 03:17
@suzuki-shunsuke suzuki-shunsuke merged commit f864eed into main Feb 28, 2024
13 checks passed
@suzuki-shunsuke suzuki-shunsuke deleted the feat-support-opentofu branch February 28, 2024 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support OpenTofu Terragrunt Support
1 participant