Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to DevOps
Infrastructure as Code with Terraform

Infrastructure as Code with Terraform

DevOps2,775 viewsBy Admin
devopsinfrastructurecodeterraform

What is Infrastructure as Code?

Infrastructure as Code (IaC) means managing servers, networks, and cloud resources through code instead of manual clicking. Terraform is the leading IaC tool.

Why IaC?

  • Reproducible — spin up identical environments.
  • Version controlled — track infra changes in Git.
  • Automated — no manual console clicking.

A Terraform Example

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

resource "aws_instance" "web" {
  ami           = "ami-12345"
  instance_type = "t2.micro"
  tags = { Name = "WebServer" }
}

The Terraform Workflow

terraform init      # download providers
terraform plan      # preview changes
terraform apply     # create/update infra
terraform destroy   # tear it all down

Key Concepts

TermMeaning
ProviderCloud platform (AWS, Azure)
ResourceThing to create (server, DB)
StateRecord of what exists

FAQs

Terraform vs Ansible?

Terraform provisions infrastructure; Ansible configures it. They complement each other. More in our DevOps guides.

Is Terraform cloud-specific?

No — it works across AWS, Azure, GCP, and more.