What is Terraform?
- Terraform = Infrastructure as Code (IaC) tool by HashiCorp.
- Lets you provision, change, and manage cloud resources using
.tffiles. - Supports multi-cloud, on-prem, SaaS, Kubernetes, etc.
- Declarative → you describe the final state, Terraform figures out how to reach it.
How Terraform Works
Write Terraform files → Run Terraform commands → Call AWS APIs through Terraform Provider
Terraform Workflow Phases:
terraform init- Initialize (downloads provider plugin)terraform validate- Validate the configuration filesterraform plan- compares the.tfconfig with the current state and shows what will be created/changed/destroyed to make desired state ( does not call API to create resources )terraform apply- Apply the changes to reach desired state (actually makes API calls)terraform destroy- Destroy the infrastructure when needed