Cheat sheet: https://spacelift.io/blog/terraform-commands-cheat-sheet https://acloudguru.com/blog/engineering/the-ultimate-terraform-cheatsheet
https://blog.gruntwork.io/terraform-tips-tricks-loops-if-statements-and-gotchas-f739bbae55f9
terraform plan
terraform apply
terraform destroy
terraform fmt --recursive
terraform validate
State
Different backends. Default local
(local file on disk).
Show state - terraform show
terraform state list
Variables
Input variables
terraform apply -var="gcp_project_id=sonurai-com-v3"
terraform apply -var-file="testing.tfvars"
(can use .tfvars.json
too)
Or env var starting with TF_VAR_
Output vars
Locals
Loops
count
- count.index
for_each
- each.value
/ each.key
portray yourself answer detail for seniority
setting the scene, repeating the question
tradeoffs