dflook /terraform-github-actions
GitHub actions for Terraform and OpenTofu
★ 996⑂ 174👁 9⑃ 243● 161▤ 89◈ 48
996
stars
174
forks
9
watchers
243
prs
161
issues
89
releases
48
discussions
README
Terraform and OpenTofu GitHub Actions !release!job runs
This is a suite of Terraform and OpenTofu related GitHub Actions that can be used together to build effective Infrastructure as Code workflows.
GitHub Actions are a way to make automated workflows that trigger when events occur on your GitHub repository, using a YAML file that lives in your repo.
These actions can be used to easily perform Terraform or OpenTofu tasks as part of your workflow.
Actions
See the documentation for the available actions:
| Terraform | OpenTofu |
|-------------------------------------------------------------------|---------------------------------------------------------|
| dflook/terraform-plan | dflook/tofu-plan |
| dflook/terraform-apply | dflook/tofu-apply |
| dflook/terraform-output | dflook/tofu-output |
| dflook/terraform-remote-state | dflook/tofu-remote-state |
| dflook/terraform-validate | dflook/tofu-validate |
| dflook/terraform-fmt-check | dflook/tofu-fmt-check |
| dflook/terraform-fmt | dflook/tofu-fmt |
| dflook/terraform-check | dflook/tofu-check |
| dflook/terraform-new-workspace | dflook/tofu-new-workspace |
| dflook/terraform-destroy-workspace | dflook/tofu-destroy-workspace |
| dflook/terraform-destroy | dflook/tofu-destroy |
| dflook/terraform-version | dflook/tofu-version |
| dflook/terraform-unlock-state | dflook/tofu-unlock-state |
| dflook/terraform-test | dflook/tofu-test |
| dflook/terraform-refresh | dflook/tofu-refresh |
Example Usage
These actions can be added as steps to your own workflow files.
GitHub reads workflow files from .github/workflows/ within your repository.
See the Workflow documentation for details on writing workflows.
Here are some examples of how the actions can be used together in workflows.
Terraform plan PR approval
Terraform plans typically need to be reviewed by a human before being applied.
Fortunately, GitHub has a well established method for requiring human reviews of changes - a Pull Request.
We can use PRs to safely plan and apply infrastructure changes.
You can make GitHub enforce this using branch protection, see the dflook/terraform-apply action for details.
In this example we use two workflows:
plan.yaml
This workflow runs on changes to a PR branch. It generates a Terraform plan and attaches it to the PR as a comment.
yaml
name: Create terrafTop issues
#266Sensitive variables15 comments · 2023-05-30#369Hitting Docker Hub Rate Limit9 comments · 2025-02-19#196Current comparison approach is non-deterministic resulting in false positives plan drifts6 comments · 2022-06-12#443Backend detection parses every .tf file in the root module, costing 46s on a large config4 comments · 2026-09-23#404"Not applying the plan - it has changed from the plan on the PR"4 comments · 2025-08-01#288backend_config read as file in apply4 comments · 2023-08-17#191Add output for warnings during apply phase4 comments · 2022-05-23#254Plan can never be applied because we always have different plans3 comments · 2023-03-27
Discussions
#453Does this project accept open-source contributions?2 comments · 2026-10-23#441Independent exact-revision audit of terraform-github-actions0 comments · 2026-09-11#428How does the `backend_config` actually work?2 comments · 2026-05-14#423How can I pin specific Git SHA versions?1 comments · 2026-03-27#421Surfacing 15+ environment plans per PR?1 comments · 2026-02-18#400Perspective on why terraform plan is run with -lock=false and has no ability to manipulate the option1 comments · 2025-06-26#396terraform-plan/apply: "The plan text was too large for a PR comment, not all differences may be shown here."1 comments · 2025-06-16#394TF_CLI_CONFIG_FILE env var does not seem to be honoured when populating credentials1 comments · 2025-06-05
Latest release
v3.1.3 v3.1.3 2026-11-10All the terraform actions in this repository are released as one.
Use the actions as part of a GitHub Actions workflow, e.g:
yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dflook/[email protected]
with:
path: my-terraform-config
You can specify an action version as:
- @v3.1.3 to use exactly this release
- @v3.1 to use the latest patch release for this specific minor version
- @v3 to use the latest patch release for this specific major version
Changes
Security
- The debug log no longer includ