validate, plan, etc.), variable usage, and passing values with environment variables — including credentials used by providers.
Getting general help
To see Terraform’s built-in usage and global options, run:taint/untaint) may still appear for backward compatibility; they are deprecated in favor of modern flags such as -replace on plan/apply.
Command-specific help
You can request help for any subcommand to see flags and usage details:validate options:
terraform validate checks configuration syntax and internal references in the module. It does not contact providers or create resources; use it to catch common errors before planning or applying.
terraform plan --help lists many plan customization options. Example (trimmed):
Using Terraform variables and environment variables
Below is an example Terraform configuration that uses a numeric variable to control thelength argument of two random_pet resources. The root output publishes the random_pet.name.id.
terraform plan without setting num_of_pets, Terraform will prompt you:
Environment variables prefixed with
TF_VAR_ map directly to input variables in the root module. For example, to set num_of_pets:
terraform plan uses that value and will not prompt:
yes when prompted):
TF_VAR_num_of_pets (for example to 6) and re-run terraform apply, the length values will reflect that updated variable value.
Environment variables prefixed with
TF_VAR_ map directly to input variables in your root module. This is a convenient way to provide non-sensitive values or CI/CD overrides without modifying configuration files.Provider credentials and environment variables
Providers (AWS, Azure, GCP, Vault, and others) typically support environment variables as one of their authentication methods. Terraform provider plugins read those variables to authenticate and perform actions on the target platform. Example: AWS provider in your configuration:Do not store sensitive credentials in source-controlled files or expose them in logs. Use secure secret management (Vault, cloud secret stores, CI/CD secrets) and ephemeral credentials where possible.
Quick reference: common CLI flags and options
Summary
- Use
terraform --helpandterraform <subcommand> --helpto discover commands and flags quickly. - Variables can be supplied interactively, via
-var/-var-file, or via environment variables (TF_VAR_<name>). - Provider credentials (AWS, Vault, etc.) are commonly supplied via environment variables; handle secrets securely.
- The CLI help pages are authoritative and the fastest reference when working with Terraform.
Links and references
- Terraform: https://www.terraform.io/
- Terraform CLI documentation: https://www.terraform.io/cli
- AWS provider docs: https://registry.terraform.io/providers/hashicorp/aws/latest/docs
- Vault provider docs: https://registry.terraform.io/providers/hashicorp/vault/latest/docs