Terraform Value Proposition
- Declarative β Describe desired state, Terraform computes the plan.
- Provider Ecosystem β AWS, Azure, GCP, Kubernetes, many SaaS services.
- State Management β Remote backends (S3, GCS) keep state consistent.
- Modular Architecture β Reusable, versioned modules.
Core Concepts
| Concept | Description |
|---|---|
| Provider | Plugin that talks to a specific API (aws, google, azurerm) |
| Resource | Managed object (e.g., aws_instance) |
| Data Source | Readβonly view of existing infrastructure |
| Module | Reusable collection of resources |
| Backend | Stores state (local, S3, Azure Storage) |
Quick Start Example (AWS EC2)
NGINX
1terraform {2 required_providers {3 aws = { source = "hashicorp/aws", version = ">= 4.0" }4 }5 backend "s3" { bucket = "my-tf-state" key = "prod/terraform.tfstate" region = "us-east-1" }6}7 8provider "aws" { region = "us-east-1" }9 10resource "aws_instance" "web" {11 ami = "ami-0c55b159cbfafe1f0"12 instance_type = "t2.micro"13 tags = { Name = "WebServer" }14}