DangKit
All Cheatsheets

Terraform Cheat Sheet

# Terraform Cheat Sheet ## Init & Plan ``` terraform init terraform plan terraform apply terraform destroy terraform state list ``` ## Resources ```hcl resource "aws_instance" "web" { ami = "ami-12345" instance_type = "t2.micro" tags = { Name = "web-server" } } ``` ## Variables ```hcl variable "region" { type = string default = "us-east-1" } output "ip" { value = aws_instance.web.public_ip } ``` ## Data Sources ```hcl data "aws_ami" "ubuntu" { most_recent = true owners = ["099720109477"] } ``` ## State ``` terraform state show aws_instance.web terraform state mv aws_instance.old aws_instance.new terraform state rm aws_instance.web ``` ## Formatting ``` terraform fmt terraform validate ```
DangKit โ€” 139+ Free Online Tools: PDF, Dev, Design, Finance & More