Show Terraform version
Print the installed Terraform CLI version and provider versions in use.
terraform versionPrint the installed Terraform CLI version and provider versions in use.
Core Terraform CLI commands for init, plan, apply, state, output, variables, workspaces, and automation.
Initialize a working directory and inspect version/help.
Print the installed Terraform CLI version and provider versions in use.
terraform versionPrint the installed Terraform CLI version and provider versions in use.
terraform -helpList Terraform subcommands and global options.
Install required providers and modules and initialize backend configuration.
terraform initInstall required providers and modules and initialize backend configuration.
Upgrade providers and modules to newest allowed versions during initialization.
terraform init -upgradeUpgrade providers and modules to newest allowed versions during initialization.
Initialize modules and providers without configuring remote/backend state.
terraform init -backend=falseInitialize modules and providers without configuring remote/backend state.
Reinitialize backend configuration without migrating existing state automatically.
terraform init -reconfigureReinitialize backend configuration without migrating existing state automatically.
Format and validate configuration before planning.
terraform fmtRewrite Terraform files to canonical style.
Format Terraform files in current directory and subdirectories.
terraform fmt -recursiveFormat Terraform files in current directory and subdirectories.
Check whether configuration is syntactically valid and internally consistent.
terraform validateCheck whether configuration is syntactically valid and internally consistent.
Emit machine-readable validation output, useful in CI.
terraform validate -jsonEmit machine-readable validation output, useful in CI.
Interactive REPL for testing expressions and inspecting values from state.
terraform consoleInteractive REPL for testing expressions and inspecting values from state.
Execute Terraform test files in the tests directory or specified test directory.
terraform testExecute Terraform test files in the tests directory or specified test directory.
Core lifecycle workflow commands.
Show the actions Terraform would take to reach the desired state.
terraform planShow the actions Terraform would take to reach the desired state.
terraform plan -out=tfplanWrite the generated plan to a file for later apply.
Set an input variable directly on the command line.
terraform plan -var='environment=prod'Set an input variable directly on the command line.
terraform plan -var-file=prod.tfvarsUse a tfvars file during planning.
terraform plan -target=aws_instance.webPlan changes for a specific resource address.
Compare state with remote objects and update state without proposing config changes.
terraform plan -refresh-onlyCompare state with remote objects and update state without proposing config changes.
terraform plan -destroyPlan destruction of all managed infrastructure.
terraform applyCreate or update infrastructure after approval.
terraform apply -auto-approveSkip interactive approval prompt.
terraform apply tfplanApply exactly the actions saved in a plan file.
Destroy all resources managed by the current configuration.
terraform destroyDestroy all resources managed by the current configuration.
Destroy infrastructure without approval prompt.
terraform destroy -auto-approveDestroy infrastructure without approval prompt.
Read outputs, state, graphs, providers, and resource dependencies.
terraform outputDisplay all output values from state.
terraform output vpc_idDisplay a single output value.
Print a string output without JSON quoting or extra formatting.
terraform output -raw vpc_idPrint a string output without JSON quoting or extra formatting.
terraform output -jsonEmit outputs as JSON for scripting.
Show human-readable representation of current state.
terraform showShow human-readable representation of current state.
terraform show tfplanInspect a previously saved plan file.
Emit a plan or state file as machine-readable JSON.
terraform show -json tfplanEmit a plan or state file as machine-readable JSON.
Print all resource addresses currently tracked in state.
terraform state listPrint all resource addresses currently tracked in state.
Display detailed attributes for one resource instance.
terraform state show aws_instance.webDisplay detailed attributes for one resource instance.
terraform providersShow provider requirements and dependency tree.
Generate a Graphviz dependency graph for visualization.
terraform graph | dot -Tpng > graph.pngGenerate a Graphviz dependency graph for visualization.
Pass variables and control Terraform with environment variables.
Fail instead of prompting for missing variables.
terraform plan -input=falseFail instead of prompting for missing variables.
Pass an input variable through environment variables.
export TF_VAR_region=us-east-1Pass an input variable through environment variables.
Inject default arguments for a specific Terraform subcommand.
export TF_CLI_ARGS_plan='-lock-timeout=60s'Inject default arguments for a specific Terraform subcommand.
Turn on Terraform internal logging for troubleshooting.
export TF_LOG=INFOTurn on Terraform internal logging for troubleshooting.
Persist Terraform debug logs to a file.
export TF_LOG_PATH=./terraform.logPersist Terraform debug logs to a file.
Store provider/plugins and local data in a custom directory.
export TF_DATA_DIR=.tfdataStore provider/plugins and local data in a custom directory.
Handle state locks and interrupted runs.
terraform force-unlock LOCK_IDRelease a stuck state lock by lock ID.
Wait for an existing state lock before failing.
terraform apply -lock-timeout=120sWait for an existing state lock before failing.
Preferred modern replacement for older refresh-only workflows.
terraform apply -refresh-onlyPreferred modern replacement for older refresh-only workflows.