github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/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 is used to validate the syntax of the terraform files. 12 Terraform performs a syntax check on all the terraform files in the directory, 13 and will display an error if any of the files doesn't validate. 14 15 This command **does not** check formatting (e.g. tabs vs spaces, newlines, comments etc.). 16 17 The following can be reported: 18 19 * invalid [HCL](https://github.com/hashicorp/hcl) syntax (e.g. missing trailing quote or equal sign) 20 * invalid HCL references (e.g. variable name or attribute which doesn't exist) 21 * same `provider` declared multiple times 22 * same `module` declared multiple times 23 * same `resource` declared multiple times 24 * invalid `module` name 25 * interpolation used in places where it's unsupported 26 (e.g. `variable`, `depends_on`, `module.source`, `provider`) 27 * missing value for a variable (none of `-var foo=...` flag, 28 `-var-file=foo.vars` flag, `TF_VAR_foo` environment variable, 29 `terraform.tfvars`, or default value in the configuration) 30 31 ## Usage 32 33 Usage: `terraform validate [options] [dir]` 34 35 By default, `validate` requires no flags and looks in the current directory 36 for the configurations. 37 38 The command-line flags are all optional. The available flags are: 39 40 * `-check-variables=true` - If set to true (default), the command will check 41 whether all required variables have been specified. 42 43 * `-no-color` - Disables output with coloring. 44 45 * `-var 'foo=bar'` - Set a variable in the Terraform configuration. This flag 46 can be set multiple times. Variable values are interpreted as 47 [HCL](/docs/configuration/syntax.html#HCL), so list and map values can be 48 specified via this flag. 49 50 * `-var-file=foo` - Set variables in the Terraform configuration from 51 a [variable file](/docs/configuration/variables.html#variable-files). If 52 "terraform.tfvars" is present, it will be automatically loaded first. Any 53 files specified by `-var-file` override any values in a "terraform.tfvars". 54 This flag can be used multiple times.