Terraform

The universal remote for the cloud. Use one language (HCL) to build infrastructure on AWS, Azure, Google Cloud, and 100+ other providers.

🧱 Core Building Blocks

1. The Provider

The plugin that talks to the API. You tell Terraform "I want to use AWS", and it downloads the AWS translator.

2. The Plan

The safety check. Before building anything, Terraform calculates exactly what it will do (Add +1, Change ~2, Destroy -0) so you can approve it.

3. The State

The "Brain". A file (terraform.tfstate) that remembers what resources exist in real life. It maps your code to the real world IDs.

đŸ•šī¸ The Universal Constructor

Mission: Write a multi-cloud config and deploy it.
Bonus: Try clicking a created server to "Sabotage" (delete) it, then run Plan/Apply to fix it (Self-Healing).

main.tf HCL
resource "aws_instance" "web" { ami = "ami-0c55b159" instance_type = "t2.micro" } resource "azurerm_vm" "db" { location = "West Europe" size = "Standard_DS1_v2" } resource "google_compute_instance" "app" { zone = "asia-east1-a" machine_type = "f1-micro" }
$ terraform init
Terraform has been successfully initialized!

$ _

🧠 Why use Terraform over CloudFormation?

Multi-Cloud Strategy

CloudFormation only works on AWS. Terraform works on AWS, Azure, Google, Kubernetes, Datadog, Cloudflare... all with the same syntax.

Modular Design

Terraform Modules let you package standard infrastructure (e.g., "Company Standard VPC") and reuse it 50 times with one line of code.

State Management

Terraform's state allows you to import existing resources, or query outputs from one stack to use in another (e.g., pass DB address to App stack).