{"id":13505895,"url":"https://github.com/cds-snc/terraform-plan","last_synced_at":"2025-05-01T21:32:16.510Z","repository":{"id":37802885,"uuid":"379599704","full_name":"cds-snc/terraform-plan","owner":"cds-snc","description":"GitHub Action to run Terraform plan and add a comment with the changes.","archived":false,"fork":false,"pushed_at":"2024-04-08T12:31:00.000Z","size":6429,"stargazers_count":55,"open_issues_count":12,"forks_count":4,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-04-11T04:13:58.344Z","etag":null,"topics":["github-actions","terraform","terragrunt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cds-snc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-06-23T12:43:44.000Z","updated_at":"2024-04-15T14:09:40.631Z","dependencies_parsed_at":"2023-10-19T23:29:01.242Z","dependency_job_id":"ac29695c-875a-40a4-b553-214099b90bad","html_url":"https://github.com/cds-snc/terraform-plan","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":"cds-snc/project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cds-snc%2Fterraform-plan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cds-snc%2Fterraform-plan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cds-snc%2Fterraform-plan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cds-snc%2Fterraform-plan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cds-snc","download_url":"https://codeload.github.com/cds-snc/terraform-plan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224278368,"owners_count":17285080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-actions","terraform","terragrunt"],"created_at":"2024-08-01T00:01:16.520Z","updated_at":"2025-05-01T21:32:16.503Z","avatar_url":"https://github.com/cds-snc.png","language":"JavaScript","funding_links":[],"categories":["Tools"],"sub_categories":["CI"],"readme":"# Terraform Plan GitHub Action\nRuns `terraform plan` on your project and posts a comment with the changes on a Pull Request (PR).  It runs the following commands:\n```sh\nterraform init\nterraform validate\nterraform fmt --check\nterraform plan -out=plan.tfplan\nterraform show -json plan.tfplan \n```\nThis action **does not** install Terraform or Terragrunt, but can be installed using [Terraform tools setup action](https://github.com/cds-snc/terraform-tools-setup).  You can see how it's used in the [pr-test.yaml workflow](.github/workflows/pr-test.yaml).\n\n# Settings\nUse the following to control the action:\n\n| Setting          |      Description                                                   |  Default     |\n|------------------|--------------------------------------------------------------------|--------------|\n| `allow-failure`  | Allow the action to fail                                           | false        |\n| `comment`        | Add comment with changes to the PR                                 | true         |\n| `comment-delete` | Delete previous comments made by the bot on the PR                 | false        |\n| `comment-title`  | The title to give the PR comment                                   | Plan changes |\n| `conftest-character-limit` | Character limit for Conftest output                      | 2000         |\n| `conftest-checks`| Location of custom conftest check definitions                      | git::https://github.com/cds-snc/opa_checks.git//aws_terraform |\n| `directory`      | Directory with the `*.tf` files to validate                        | .            |\n| `github-token`   | GitHub Token used to add comment to PR (required to add comments). |              |\n| `plan-character-limit` | Character limit for Terraform plan output                    | 30000        |\n| `terraform-init` | Custom Terraform init args                                         |              |\n| `terraform-plan` | Custom Terraform plan args                                         |              |\n| `terragrunt`     | Use Terragrunt instead of Terraform                                | false        |\n| `skip-conftest`  | Skip the Conftest step                                             | false        |\n| `skip-fmt`       | Skip the Terraform format check                                    | false        |\n| `skip-plan`      | Skip the Terraform plan for projects without a remote state        | false        |\n| `init-run-all`   | Run init across all modules (only applicable for terragrunt).      | false        |\n\n\n# Examples\n```yaml\n# Setup Terraform, Terragrunt, and Conftest\n- name: Setup terraform tools\n  uses: cds-snc/terraform-tools-setup@v1\n\n# Run Terraform plan and add a comment with changes on the PR\n- name: Terraform plan\n  uses: cds-snc/terraform-plan\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n\n# Use Terragrunt, allow failure and set a custom PR comment title\n- name: Terraform plan\n  uses: cds-snc/terraform-plan\n  with:\n    allow-failure: true\n    comment-title: Custom comment title\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    terragrunt: true\n\n# Run on a sub project folder, deleting previous PR comments made by the action\n- name: Terraform plan\n  uses: cds-snc/terraform-plan\n  with:\n    directory: ./infra\n    comment-delete: true\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n\n# Run Terraform plan with no PR comment\n# Plan will still availabe in the workflow logs\n- name: Terraform plan\n  uses: cds-snc/terraform-plan\n  with:\n    add-comment: false\n\n# Run Terraform plan custom Terraform init args\n- name: Terraform plan\n  uses: cds-snc/terraform-plan\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    terraform-init: |\n      -backend-config=\"bucket=your-state-bucket-name\"\n      -backend-config=\"region=ca-central-1\"\n\n# Run Terraform plan custom Terraform plan args\n- name: Terraform plan with variable file\n  uses: cds-snc/terraform-plan\n  with:\n    github-token: ${{ secrets.GITHUB_TOKEN }}\n    terraform-plan: |\n      -var-file=\"path/to/terraform.tfvars\"\n```\n\n# Contributing\nTo setup your local dev environment:\n```sh\nnpm install\nnpm run prepare\n```\nHusky provides a pre-commit hook that builds the `dist/index.js` used by the action.  To test locally, [nektos/act](https://github.com/nektos/act) works well.\n\n# Policy\n[Open Policy Agent](https://www.openpolicyagent.org/) is used to check the `terraform plan` for changes.  [Policies](./policy) are written in Rego and then compiled into a WebAssembly module using `npm run policy`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcds-snc%2Fterraform-plan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcds-snc%2Fterraform-plan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcds-snc%2Fterraform-plan/lists"}