Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 629 across 38 tools. Pick a tool in the sidebar, or search across all of them.
Terraform
Provision infrastructure as code - plan, apply, and manage state.| Command | What it does | Example |
|---|---|---|
terraform init | Download providers and set up the working directory. | terraform init |
terraform plan | Preview what would change, without touching anything. | terraform plan |
terraform apply | Make the infrastructure match the config. | terraform apply |
terraform apply -auto-approve | Apply without the interactive prompt (CI). | terraform apply -auto-approve |
terraform destroy | Tear down everything the config manages. | terraform destroy |
terraform fmt | Auto-format .tf files. | terraform fmt -recursive |
terraform validate | Check syntax and internal consistency. | terraform validate |
terraform plan -out | Save a plan so apply runs exactly that. | terraform plan -out=tfplan |
terraform output | Print an output value (great in scripts). | terraform output -raw db_endpoint |
terraform state list | List every resource in the state. | terraform state list |
terraform state show | Show a resource's attributes from state. | terraform state show aws_instance.web |
terraform apply -target | Apply just one resource (sparingly). | terraform apply -target=aws_s3_bucket.assets |
terraform apply -replace | Force a resource to be recreated. | terraform apply -replace=aws_instance.web |
terraform import | Bring an existing resource under management. | terraform import aws_instance.web i-0abc123 |
terraform workspace new | Create a separate state, e.g. per environment. | terraform workspace new staging |
terraform workspace select | Switch to another workspace. | terraform workspace select prod |
terraform state rm | Forget a resource without destroying it. | terraform state rm aws_s3_bucket.legacy |