Introduction
Every application needs infrastructure: servers, databases, networks, DNS records. The old way to create them is clicking through cloud consoles β slow, error-prone, and impossible to reproduce exactly. Terraform, from HashiCorp, takes a different approach: you describe the infrastructure you want in configuration files, and Terraform creates it, updates it, and tracks it for you. Infrastructure as code, in the same way your application is code.
Configuration: describe, don't click
A Terraform file declares resources β things you want to exist β in a readable language called HCL:
resource "aws_instance" "web" { ami = "ami-12345678" instance_type = "t3.micro" tags = { Name = "web-server" } }
Enter fullscreen mode
Exit fullscreen mode
Run terraform apply , and Terraform creates that server in AWS. Change t3.micro to t3.small and apply again, and Terraform resizes it. Delete the block and apply, and it destroys the server.β¦