DevOps & Cloud

Terraform: Infrastructure as Code for Cloud Resources

February 22, 2026 1 min read 6 views

Terraform by HashiCorp is the leading Infrastructure as Code (IaC) tool, supporting over 3,000 providers including AWS, Azure, GCP, and DigitalOcean. Instead of clicking through cloud consoles, you declare your desired infrastructure in HCL files.

Why Infrastructure as Code?

  • Reproducibility — identical staging and production environments
  • Version control — review infrastructure changes in pull requests
  • Automation — no manual clicking, no missed steps
  • Documentation — your code IS the documentation

Basic AWS Example

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t3.micro"
  tags = {
    Name        = "web-server"
    Environment = "production"
  }
}

resource "aws_db_instance" "database" {
  allocated_storage    = 20
  engine               = "mysql"
  engine_version       = "8.0"
  instance_class       = "db.t3.micro"
  db_name              = "myapp"
  username             = var.db_username
  password             = var.db_password
  skip_final_snapshot  = true
}

Terraform Workflow

terraform init    # Initialize providers
terraform plan    # Preview changes
terraform apply   # Apply changes
terraform destroy # Destroy all resources

State Management

Terraform tracks resources in a state file. For teams, store state remotely:

terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "prod/terraform.tfstate"
    region = "us-east-1"
  }
}

Terraform turns infrastructure from a manual process into a code-review-friendly, automated workflow.

Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!