What is Terraform?
Terraform is an open-source Infrastructure as Code tool by HashiCorp. You describe infrastructure in HCL (HashiCorp Configuration Language), and Terraform creates, updates, or destroys cloud resources to match.
Use it to:
- Create infrastructure
- Modify infrastructure
- Delete infrastructure
All from code.
Why Terraform?
- Multi-cloud — AWS, Azure, GCP, and hundreds of providers
- Open source — large community and provider ecosystem
- Declarative — describe desired state, not step-by-step scripts
- State management — tracks what already exists
- Reusable modules — package and share common patterns
- Version control friendly —
.tffiles live in Git
Terraform vs CloudFormation
| Terraform | CloudFormation |
|---|---|
| Multi-cloud | AWS only |
| Open source | AWS service |
| HCL | JSON / YAML |
| Broad provider ecosystem | AWS resources only |
Terraform Architecture
.tf configuration files
↓
Terraform Core
(plan + apply)
↓
Providers
(aws, azurerm, …)
↓
Cloud APIs
↓
Resources
(EC2, S3, VPC, …)
Components
Terraform configuration — .tf files that declare providers and resources.
Terraform Core — reads config and state, builds an execution plan, and applies changes.
Provider — plugin that knows how to talk to a specific platform (for example hashicorp/aws).
Cloud APIs — the real create/update/delete calls made on your behalf.
Resources — the individual objects you manage (aws_instance, aws_s3_bucket, …).
Terraform Workflow
Write .tf code
↓
terraform init
↓
terraform plan
↓
terraform apply
↓
Infrastructure created
Important commands
terraform init # download providers, prepare the working directory
terraform plan # preview what will change
terraform apply # create / update infrastructure
terraform destroy # tear everything down
terraform validate # check syntax and basic configuration
terraform version # show installed versionAlways run plan before apply in shared or production environments so you can review the blast radius.