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

     1  ---
     2  layout: "docs"
     3  page_title: "Command: validate"
     4  sidebar_current: "docs-commands-validate"
     5  description: |-
     6    The `terraform validate` command is used to validate the syntax of the terraform files.
     7  ---
     8  
     9  # Command: validate
    10  
    11  The `terraform validate` command validates the configuration files in a
    12  directory, referring only to the configuration and not accessing any remote
    13  services such as remote state, provider APIs, etc.
    14  
    15  Validate runs checks that verify whether a configuration is syntactically
    16  valid and internally consistent, regardless of any provided variables or
    17  existing state. It is thus primarily useful for general verification of
    18  reusable modules, including correctness of attribute names and value types.
    19  
    20  It is safe to run this command automatically, for example as a post-save
    21  check in a text editor or as a test step for a re-usable module in a CI
    22  system.
    23  
    24  Validation requires an initialized working directory with any referenced
    25  plugins and modules installed. To initialize a working directory for
    26  validation without accessing any configured remote backend, use:
    27  
    28  ```
    29  $ terraform init -backend=false
    30  ```
    31  
    32  If dir is not specified, then the current directory will be used.
    33  
    34  To verify configuration in the context of a particular run (a particular
    35  target workspace, input variable values, etc), use the `terraform plan`
    36  command instead, which includes an implied validation check.
    37  
    38  ## Usage
    39  
    40  Usage: `terraform validate [options] [dir]`
    41  
    42  By default, `validate` requires no flags and looks in the current directory
    43  for the configurations.
    44  
    45  The command-line flags are all optional. The available flags are:
    46  
    47  - `-json` - Produce output in a machine-readable JSON format, suitable for
    48    use in text editor integrations and other automated systems. Always disables
    49    color.
    50  
    51  - `-no-color` - If specified, output won't contain any color.