terraform init
Initializes a Terraform working directory. Downloads providers and sets up backend. Run this first.
terraform plan
Creates an execution plan, showing what will change without applying it. Useful to review before changes.
terraform apply
Applies the changes required to reach the desired state. Creates/updates infrastructure.
terraform destroy
Destroys all resources managed by Terraform in the current configuration.
terraform validate
Checks whether the configuration is syntactically valid (but doesn’t check if it's correct against the cloud provider).
terraform fmt
Formats the configuration files to a standard style. Use this to keep code clean and readable.
terraform show
Displays the current state or a saved plan in a readable form.
terraform output
Prints the outputs of your configuration. Often used in scripts or to extract info post-deployment.
terraform refresh
Updates the state file with real-world infrastructure (deprecated in Terraform 1.5+).
terraform graph
Generates a visual graph of Terraform resources and dependencies (in DOT format).
terraform state list
Lists all resources in the current state file.
terraform state show [resource]
Shows detailed information about a resource in the state file.
terraform state rm [resource]
Removes a resource from the state (use with caution).
terraform state mv
Moves items within the state file (e.g., renaming or refactoring modules).
terraform state pull
Pulls and prints the raw state file.
terraform state push
Overwrites remote state with a local state file.
terraform get
Downloads modules referenced in the configuration.
terraform providers
Lists the providers required by the configuration.
terraform providers lock
Generates a dependency lock file for Terraform providers.
terraform providers mirror
Copies provider plugins to a local directory.
terraform workspace list
Lists all available workspaces.
terraform workspace new [name]
Creates a new workspace (e.g., dev, staging, prod).
terraform workspace select [name]
Switches to the specified workspace.
terraform workspace delete [name]
Deletes a workspace.
terraform login
Authenticates with Terraform Cloud or Terraform Enterprise.
terraform logout
Logs out of Terraform Cloud.
terraform cloud
Manages settings for Terraform Cloud or Enterprise.