Back to Cheat Sheets

Terraform Commands

Commands to manage infrastructure as code with Terraform.

Action Command Details
Initialize terraform init Prepare working directory for Terraform.
Format config terraform fmt Format Terraform configuration files.
Validate config terraform validate Check syntax and config validity.
Plan terraform plan Preview changes before applying.
Apply terraform apply Apply changes to infrastructure.
Destroy terraform destroy Remove managed infrastructure.
State list terraform state list List resources in the state file.
Import terraform import <resource> <id> Import existing resource into state.
Output terraform output Show output variables.
Refresh terraform refresh Update state file with real infrastructure state.
Workspace list terraform workspace list List available workspaces.
Select workspace terraform workspace select <name> Switch workspace.
LoopPlunk
Support Us