đĽď¸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