Write Code (.tf files)
|
v
terraform init <-- Downloads provider plugins, sets up backend
|
v
terraform validate <-- Checks syntax errors
|
v
terraform plan <-- Compares current state vs desired state, shows diff
|
v
terraform apply <-- Applies the changes to real infrastructure
|
v
State File Updated <-- terraform.tfstate updated with new real state
|
v
terraform destroy <-- Destroys all managed resources (when needed)
project/
├── main.tf # Main resources
├── variables.tf # Input variable declarations
├── outputs.tf # Output value declarations
├── provider.tf # Provider configuration
├── terraform.tfvars # Actual variable values
├── backend.tf # Remote state backend config
└── .terraform/ # Local plugins/cache (auto-generated by init)
Terraform is an open-source Infrastructure as Code (IaC) tool by HashiCorp. It lets you define cloud infrastructure (servers, databases, networks) in .tf files and manage them through code.
Why use Terraform:
IaC means managing and provisioning infrastructure through code/config files instead of manually clicking in a cloud console.
Benefits: