What is Infrastructure as Code (IaC)?
In the past, setting up servers required manually clicking buttons on cloud dashboards or running CLI scripts. Infrastructure as Code (IaC) allows developers to write code configuration files defining networking, databases, and servers. This ensures infrastructure is predictable, version-controlled, and reproducible. Terraform (developed by HashiCorp) is the leading tool in this domain.
Core Terraform Concepts
Terraform uses HashiCorp Configuration Language (HCL) to define configuration parameters. Key blocks include Providers, Resources, Variables, and Outputs.
Terraform HCL Syntax Example
# Configure the AWS Provider
provider "aws" {
region = "ap-south-1" # Mumbai region
}
# Provision an EC2 instance
resource "aws_instance" "web_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
tags = { Name = "IndoreWebServer" }
}
Terraform Commands Lifecycle
| Command | Lifecycle Step | Action Performed |
|---|---|---|
| terraform init | 1. Initialize | Downloads required provider plugins (AWS/Azure/GCP modules) |
| terraform plan | 2. Dry Run | Analyzes files, displaying changes that will be applied to the cloud |
| terraform apply | 3. Provision | Deploys the resource structures directly to your cloud provider |
| terraform destroy | 4. Clean up | Deletes all provisioned infrastructure defined in the configuration files |
Beginner Terraform Checklist
- Install Terraform CLI on your local OS
- Set up cloud provider credentials (e.g. AWS access keys) safely
- Write an HCL script to configure a basic resource (S3 bucket or VM instance)
- Understand the role of the
terraform.tfstateconfiguration file
Frequently Asked Questions (FAQs)
Terraform is declarative: you define the desired state, and Terraform handles the execution plan. If a resource exists, Terraform ignores it; a shell script would try to recreate it, resulting in runtime errors.
Teams save the state file in a remote backend (like AWS S3) with State Locking configured through a database (like DynamoDB) to prevent simultaneous deployments from corrupting files.
Upskill in DevOps infrastructure. Start provisioning code configurations and apply to DevOps job opportunities on IND Job Circle.
Career & IT Editorial Experts
We are a team of tech recruiters, software engineers, and industry mentors dedicated to helping professionals in Indore and across India build high-growth IT careers.