🖥️Deploy Your First EC2 with Terraform (Step-by-Step Guide) — Part 3
In the previous post, you set up Terraform and AWS CLI. Now it’s time to do what really matters: 👉 Build real infrastructure using code By the end of this guide, you’ll launch an EC2 instance usin...

Source: DEV Community
In the previous post, you set up Terraform and AWS CLI. Now it’s time to do what really matters: 👉 Build real infrastructure using code By the end of this guide, you’ll launch an EC2 instance using Terraform — no AWS Console clicks required. 🎯 What You’ll Build We’ll create: An EC2 instance Using Terraform In just a few lines of code 📁 Step 1 — Create Project Structure Create a new folder: mkdir terraform-ec2 cd terraform-ec2 Create files: touch provider.tf main.tf 🔹 Step 2 — Configure AWS Provider Open provider.tf: provider "aws" { region = "ap-southeast-1" } 🔹 Step 3 — Create EC2 Instance Open main.tf: resource "aws_instance" "web_server" { ami = "ami-xxxxxxxxxxxx" instance_type = "t2.micro" tags = { Name = "terraform-server" } } ⚠️ Replace the AMI with a valid one from your AWS region. 🔹 Step 4 — Initialize Terraform terraform init This downloads the AWS provider and prepares your project. 🔹 Step 5 — Preview Changes terraform plan Terraform will show something like: Plan: 1 t