Terraform Micro Cheatsheet
Daily Driver
terraform init→ Initialize working directoryterraform plan→ Preview changes before applyterraform apply→ Apply changes to infrastructureterraform destroy→ Tear down infrastructureterraform fmt→ Format code to standard styleterraform validate→ Validate syntax and configsterraform state list→ Show tracked resourcesterraform state show→ Inspect resource detailsterraform refresh→ Sync state with real infrastructureterraform taint <res>→ Force resource recreationTF_LOG=DEBUG terraform apply→ Enable detailed logs
Mnemonic: Init → Plan → Apply → Destroy → Format → Validate → State → Refresh → Debug.
Basics & Workflow
Purpose: Quick reference for everyday Terraform commands and project setup.
- 1.1 Commands Cheatsheet
- Core commands:
init,plan,apply,destroy,fmt,validate. - State commands:
state list,state show,refresh,taint. - Debugging flag:
TF_LOG. - Mnemonic: “Init → Plan → Apply → Destroy → Format → Validate → State → Refresh.”
- Core commands:
- 1.2 File Structure Cheatsheet
.tffiles: main, variables, outputs.terraform.tfstateandterraform.tfvars.- Module folder layout.
- Mnemonic: “Main → Vars → Outputs → State → Modules.”
- 1.3 State Management Cheatsheet
- Local vs remote state.
- Commands:
state list,state rm,state mv. - Workspaces for environment separation.
- Mnemonic: “List → Show → Refresh → Move → Remote.”
Core Constructs
Purpose: Syntax and usage of Terraform’s building blocks.
- 2.1 Providers Cheatsheet
- Provider block syntax.
- Authentication methods (AWS, Azure, GCP).
- Aliases for multi‑provider configs.
- 2.2 Resources Cheatsheet
- Resource block syntax.
- Arguments, lifecycle rules (
create_before_destroy,prevent_destroy). - Dependencies (
depends_on).
- 2.3 Variables & Outputs Cheatsheet
- Variable types: string, number, bool, list, map.
- Default values, sensitive variables.
- Outputs with
outputblocks.
- 2.4 Data Sources Cheatsheet
- Syntax:
data "aws_ami" "example" {}. - Fetching external info (AMI IDs, secrets).
- Linking data sources to resources.
- Syntax:
Advanced Features
Purpose: Tools for scaling and complex deployments.
- 3.1 Modules Cheatsheet
- Module syntax:
source,version. - Input/output variables.
- Best practices for reusability.
- Module syntax:
- 3.2 Expressions Cheatsheet
- Interpolation:
${var.name}. - Conditionals:
count = var.enabled ? 1 : 0. - Loops:
for_each,count.
- Interpolation:
- 3.3 Provisioners Cheatsheet
local-execandremote-exec.- When to use vs configuration management tools.
- 3.4 Workspaces Cheatsheet
- Commands:
workspace new,workspace select,workspace list. - Use cases: dev, staging, prod separation.
- Commands:
Cloud‑Specific
Purpose: Quick reference for common resources in each cloud.
- 4.1 AWS Cheatsheet
- VPC, Subnets, Security Groups.
- EC2, S3, RDS, ALB basics.
- 4.2 Azure Cheatsheet
- Resource Group, VNet, NSG.
- VM, Blob Storage, SQL Database.
- 4.3 GCP Cheatsheet
- VPC, Firewall rules.
- Compute Engine, Cloud Storage, Cloud SQL.
Multi‑Cloud & Collaboration
Purpose: Managing multiple providers and team workflows.
- 5.1 Multi‑Cloud Providers Cheatsheet
- AWS + Azure + GCP provider blocks.
- Aliases for multiple regions/providers.
- 5.2 Terraform Cloud Cheatsheet
- Workspaces, remote state.
- Sentinel policies.
- Variable sets.
- 5.3 CI/CD Cheatsheet
- Pipeline stages: validate, plan, apply.
- GitHub Actions config snippet.
- Best practices for approvals.
Debugging & Governance
Purpose: Troubleshooting and enforcing compliance.
- 6.1 Debugging Cheatsheet
- Commands:
plan,refresh,taint. - Logs:
TF_LOG=DEBUG. - Drift detection.
- Commands:
- 6.2 Governance Cheatsheet
- Tagging standards.
- Sentinel/OPA policy examples.
- Cost optimization tips (Infracost, reserved instances).
The Hackers Notebook
This detailed plan ensures each cheatsheet is category‑focused, bite‑sized, and practical. Learners can use them as quick references during projects, interviews, or daily DevOps work.

Updated on Dec 24, 2025