Infrastructure as Code (IaC) is a DevOps approach where infrastructure is defined and managed using code instead of manual setup. This makes environments reproducible, version-controlled, and easy to scale.
In this guide, you'll provision an AWS EC2 instance using Terraform.
Requirements
Before starting, install:
Terraform
AWS CLI
AWS Credentials Setup
Go to IAM → Security credentials in AWS
Create access keys
Configure locally:
aws configure
Enter fullscreen mode
Exit fullscreen mode
This stores credentials in:
~/.aws/credentials
~/.aws/config
Project Structure
A simple Terraform setup:
.…