github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/fmt.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Command: fmt"
     4  sidebar_current: "docs-commands-fmt"
     5  description: |-
     6    The `terraform fmt` command is used to rewrite Terraform configuration files to a canonical format and style.
     7  ---
     8  
     9  # Command: fmt
    10  
    11  The `terraform fmt` command is used to rewrite Terraform configuration files
    12  to a canonical format and style. This command applies a subset of
    13  the [Terraform language style conventions](/docs/configuration/style.html),
    14  along with other minor adjustments for readability.
    15  
    16  Other Terraform commands that generate Terraform configuration will produce
    17  configuration files that conform to the style imposed by `terraform fmt`, so
    18  using this style in your own files will ensure consistency.
    19  
    20  The canonical format may change in minor ways between Terraform versions, so
    21  after upgrading Terraform we recommend to proactively run `terraform fmt`
    22  on your modules along with any other changes you are making to adopt the new
    23  version.
    24  
    25  ## Usage
    26  
    27  Usage: `terraform fmt [options] [DIR]`
    28  
    29  By default, `fmt` scans the current directory for configuration files. If
    30  the `dir` argument is provided then it will scan that given directory
    31  instead. If `dir` is a single dash (`-`) then `fmt` will read from standard
    32  input (STDIN).
    33  
    34  The command-line flags are all optional. The list of available flags are:
    35  
    36  * `-list=false` - Don't list the files containing formatting inconsistencies.
    37  * `-write=false` - Don't overwrite the input files. (This is implied by `-check` or when the input is STDIN.)
    38  * `-diff` - Display diffs of formatting changes
    39  * `-check` - Check if the input is formatted. Exit status will be 0 if
    40      all input is properly formatted and non-zero otherwise.
    41  * `-recursive` - Also process files in subdirectories. By default, only the given directory (or current directory) is processed.