Terraform: TF 0.12: `terraform validate -check-variables` flag not defined

Created on 26 May 2019  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.12.0

Terraform Configuration Files

N/A

Debug Output

2019/05/26 09:44:45 [INFO] Terraform version: 0.12.0  
2019/05/26 09:44:45 [INFO] Go runtime version: go1.12.4
2019/05/26 09:44:45 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/0.6.0/versions/0.12.0/terraform", "validate", "-check-variables=true"}
2019/05/26 09:44:45 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc
2019/05/26 09:44:45 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/05/26 09:44:45 [INFO] CLI command args: []string{"validate", "-check-variables=true"}

Expected Behavior

If set to true (default), the command will check whether all required variables have been specified.

Reference: https://www.terraform.io/docs/commands/validate.html#check-variables-true

Actual Behavior

Exit code 1.

flag provided but not defined: -check-variables
Usage: terraform validate [options] [dir]

  Validate the configuration files in a directory, referring only to the
  configuration and not accessing any remote services such as remote state,
  provider APIs, etc.

  Validate runs checks that verify whether a configuration is
  internally-consistent, regardless of any provided variables or existing
  state. It is thus primarily useful for general verification of reusable
  modules, including correctness of attribute names and value types.

  It is safe to run this command automatically, for example as a post-save
  check in a text editor or as a test step for a re-usable module in a CI
  system.

  Validation requires an initialized working directory with any referenced
  plugins and modules installed. To initialize a working directory for
  validation without accessing any configured remote backend, use:
      terraform init -backend=false

  If dir is not specified, then the current directory will be used.

  To verify configuration in the context of a particular run (a particular
  target workspace, operation variables, etc), use the terraform plan
  subcommand instead, which includes an implied validation check.

Options:

  -json        Produce output in a machine-readable JSON format, suitable for
               use in e.g. text editor integrations.

Steps to Reproduce

Run either terraform validate -check-variables=true or terraform validate -check-variables=false

Most helpful comment

There is a mention here that the flag would not be available anymore with 0.12 but that they have not updated the doc yet.
https://github.com/hashicorp/terraform/issues/21408#issuecomment-495259124
It seems now if you want the validation with variables like that you need to run terraform plan

All 3 comments

There is a mention here that the flag would not be available anymore with 0.12 but that they have not updated the doc yet.
https://github.com/hashicorp/terraform/issues/21408#issuecomment-495259124
It seems now if you want the validation with variables like that you need to run terraform plan

I was assuming something like that but got confused by the documentation. Thank you!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings