The terraform validate command is used to validate the syntax of the terraform files. Terraform performs a syntax check on all the terraform files in the directory, and will display an error if any of the files doesn't validate.
This command does not check formatting (e.g. tabs vs spaces, newlines, comments etc.).
The following can be reported:
provider declared multiple times module declared multiple times resource declared multiple times module name variable, depends_on, module.source, provider) -var foo=... flag, -var-file=foo.vars flag, TF_VAR_foo environment variable, terraform.tfvars, or default value in the configuration) Usage: terraform validate [options] [dir]
By default, validate requires no flags and looks in the current directory for the configurations.
The command-line flags are all optional. The available flags are:
-check-variables=true - If set to true (default), the command will check whether all required variables have been specified.
-no-color - Disables output with coloring.
-var 'foo=bar' - Set a variable in the Terraform configuration. This flag can be set multiple times. Variable values are interpreted as HCL, so list and map values can be specified via this flag.
-var-file=foo - Set variables in the Terraform configuration from a variable file. If "terraform.tfvars" is present, it will be automatically loaded first. Any files specified by -var-file override any values in a "terraform.tfvars". This flag can be used multiple times.
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/commands/validate.html