Cloud
Terraform Cloud CLI
Terraform Cloud CLI commands for remote state and workspaces.
29 commands
Windows
MacOS
Linux
#infrastructure
#terraform
Authentication
Authenticate with Terraform Cloud
terraform login
Login to specific hostname
terraform login app.terraform.io
Remove stored credentials
terraform logout
Show Terraform and provider versions
terraform version
Workspace Management
List all workspaces
terraform workspace list
Create a new workspace
terraform workspace new staging
Switch to a workspace
terraform workspace select staging
Show current workspace
terraform workspace show
Delete a workspace
terraform workspace delete staging
Run Management
Initialize with remote backend
terraform init
Create an execution plan
terraform plan
Apply changes via Terraform Cloud
terraform apply
Apply without confirmation
terraform apply -auto-approve
Destroy managed infrastructure
terraform destroy
Apply specific resource only
terraform apply -target=aws_instance.web
Variables
Pass variable on command line
terraform plan -var="region=us-west-2"
Use variable file
terraform plan -var-file="staging.tfvars"
Apply with variable override
terraform apply -var="instance_type=t3.large"
Set variable via environment
export TF_VAR_region=us-west-2
Open interactive console
terraform console
State
List resources in state
terraform state list
Show resource details
terraform state show aws_instance.web
Download remote state locally
terraform state pull
Rename resource in state
terraform state mv aws_instance.web aws_instance.api
Remove resource from state
terraform state rm aws_instance.web
Release a stuck state lock
terraform force-unlock LOCK_ID
Quick Commands
Authenticate with Terraform Cloud
terraform login
List all workspaces
terraform workspace list
List all resources in remote state
terraform state list