terraform-github-actions

terraform-validate action

This is one of a suite of Terraform related actions - find them at dflook/terraform-github-actions.

This action uses the terraform validate command to check that a Terraform configuration is valid. This can be used to check that a configuration is valid before creating a plan.

Failing GitHub checks will be added for any problems found.

If the Terraform configuration is not valid, the build is failed.

Inputs

Outputs

Environment Variables

Example usage

This example workflow runs on every push and fails if the Terraform configuration is invalid.

on: [push]

jobs:
  validate:
    runs-on: ubuntu-latest
    name: Validate Terraform module
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: terraform validate
        uses: dflook/terraform-validate@v1
        with:
          path: my-terraform-config

This example executes a run step only if the validation failed.

on: [push]

jobs:
  validate:
    runs-on: ubuntu-latest
    name: Validate Terraform module
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: terraform validate
        uses: dflook/terraform-validate@v1
        id: validate
        with:
          path: my-terraform-config

      - name: Validate failed
        if: $
        run: echo "terraform validate failed"