I Automated My First AWS Project with Terraform — Here's What I Learned as a Beginner
My first hands-on experience moving from clicking around the AWS console to managing infrastructure with Terraform. What broke, what clicked, and a simple project you can copy to start your own automation journey.
For months, I only used the AWS Console. Click, configure, launch, repeat. It worked, but I had no idea what "Infrastructure as Code" actually meant until I tried Terraform myself. Here's what I learned.
Why I moved away from the console
Every time I rebuilt a lab, I had to remember every click: which subnet, which security group rule, which AMI. One day I deleted a VPC that had other things attached to it, and spent an hour untangling the mess. That's when I understood why engineers use code instead of console clicks: repeatability and safety.
My first Terraform project
I started small: deploy an EC2 instance inside a custom VPC, with a security group that only allows SSH from my IP.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
provider "aws" {
region = "ap-south-1"
}
resource "aws_vpc" "my_vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "my_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "10.0.1.0/24"
}
resource "aws_security_group" "my_sg" {
vpc_id = aws_vpc.my_vpc.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["YOUR_IP/32"]
}
}
resource "aws_instance" "my_ec2" {
ami = "ami-xxxxxxxx"
instance_type = "t2.micro"
subnet_id = aws_subnet.my_subnet.id
vpc_security_group_ids = [aws_security_group.my_sg.id]
}Three commands later, my infrastructure existed:
1
2
3
terraform init
terraform plan
terraform applyWhat went wrong (and what I learned)
- I hardcoded my IP and forgot to update it later. Fix: use a variable, not a literal value.
- I ran
terraform destroywithout checking what it would remove. Fix: always runterraform planorterraform destroy -targetcarefully, and never run destroy on shared infrastructure without reviewing the plan. - I didn't store state remotely. My local
.tfstatefile is a single point of failure. Fix: use an S3 backend with DynamoDB locking for any real project.
Why this matters more than console skills alone
Recruiters and interviewers increasingly ask about Infrastructure as Code, not just "can you launch an EC2 instance." Knowing Terraform or CloudFormation shows you understand version control, repeatability, and team collaboration in infrastructure, not just individual tasks.
Try it yourself
- Install Terraform locally
- Create an IAM user with limited permissions for testing (never use root)
- Copy the code above, replace the AMI ID and your IP
- Run
terraform planfirst, always - Destroy everything when done, so you don't get billed for idle resources
Your turn
Have you tried Terraform or CloudFormation yet? What was your first "oh no" moment? Share it below, I'd love to hear what tripped you up. If this helped, a like means a lot and helps other beginners find it. 🙌
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article