Skip to content

Updates Pull Requests with visual diff of Terraform Plan changes

License

Notifications You must be signed in to change notification settings

ahmadnassri/action-terraform-report

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Action: Terraform Pull Request Report Generator

license version super linter release

Updates Pull Requests with visual diff of Terraform Plan changes

Usage

name: terraform-plan

on:
  pull_request:

jobs:
  terraform-plan:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: hashicorp/setup-terraform@v1
      - run: terraform init
      - run: terraform validate
      - run: terraform plan -lock=false -out terraform.plan
      - run: terraform show -json terraform.plan
        id: show
      # store output into a file
      - run: |
          cat > terraform.json << 'EOM'
          ${{ steps.show.outputs.stdout }}
          EOM

      - uses: ahmadnassri/action-terraform-report@v1
        with:
          # tell the action where to find the json file
          terraform-plan: ${{ github.workspace }}/terraform.json

Inputs

input required default description
terraform-plan - path to Terraform JSON file generated with terraform show
github-token github.token The GitHub token used to update the pull-request