Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
globe

GitHub Action

terraform-fmt

v1.5.1

terraform-fmt

globe

terraform-fmt

Rewrite terraform files into canonical format

Installation

Copy and paste the following snippet into your .yml file.

              

- name: terraform-fmt

uses: dflook/terraform-fmt@v1.5.1

Learn more about this action in dflook/terraform-fmt

Choose a version

terraform-fmt action

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

This action uses the terraform fmt command to reformat files in a directory into a canonical format.

Inputs

  • path

    Path to the terraform configuration

    • Type: string
    • Required

Example usage

This example automatically creates a pull request to fix any formatting problems that get merged into the master branch.

name: Fix terraform file formatting

on:
  push:
    branches:
      - master

jobs:
  format:
    runs-on: ubuntu-latest
    name: Check terraform file are formatted correctly
    steps:
      - name: Checkout
        uses: actions/checkout@v2

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

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v2
        with:
          commit-message: terraform fmt
          title: Reformat terraform files
          body: Update terraform files to canonical format using `terraform fmt`
          branch: automated-terraform-fmt