DEV Community

Salma22C
Salma22C

Posted on

Zero to EC2: My First Terraform Project as a Cloud Beginner πŸš€

πŸ“Œ TL;DR

A step-by-step guide on how I used Terraform to provision an EC2 instance on AWS with full monitoring, VPC networking, IAM roles, and CloudWatch logs β€” all as part of my learning journey as a junior cloud engineer.

πŸ‘‹ Introduction
🟒 Why I chose Terraform + AWS
🟒 My goal: Learn Infrastructure as Code by building, not just reading
🟒 This project: EC2 + VPC + Monitoring + Logging using Terraform

🧱 What I Built

βœ… A custom VPC with public & private subnets
βœ… A t2.micro EC2 instance with detailed monitoring
βœ… A security group that allows SSH (port 22)
βœ… CloudWatch integration with VPC Flow Logs
βœ… IAM roles and policies to support secure logging

πŸ”§ Tools & Requirements
Terraform >= 1.3.0
AWS CLI (aws configure)
An AWS account with appropriate permissions
Basic knowledge of networking (CIDR blocks, subnets)

πŸ“‚ File Structure Overview

πŸ”— main.tf: Core infrastructure
πŸ”— variables.tf: Input variables
πŸ”— terraform.tfvars: Your custom deployment config
πŸ”— outputs.tf: Public IP, subnet IDs, etc.
πŸ”—providers.tf: AWS provider setup
πŸ”—.gitignore(Optional):Ignore Terraform-generated files

βš™οΈ Configuration

Example terraform.tfvars:

region = "us-east-1"
vpc_cidr = "10.0.0.0/16"
public_subnets = ["10.0.1.0/24"]
private_subnets = ["10.0.2.0/24"]
instance_type = "t2.micro"
ami_id = "ami 0abcdef1234567890"
key_name = "your-key-name"

πŸš€ Deploying with Terraform

Step 1: Initialize
terraform init
Step 2: Plan changes
terraform plan
Step 3: Apply the configuration
terraform apply

🧠 What I Learned

Terraform structure: Broke code into logical files
Security:Scoped IAM and used safe CIDR blocks
Logs: Learned to trace logs in CloudWatch
Debugging:Fixed syntax and reference issues using Terraform CLI
Dependencies:Understood depends_on and implicit graphs

βœ… Terraform Outputs

After deployment, you get:
🌍 Public IP of the EC2 instance
πŸ“˜ CloudWatch Log Group name
🌐 VPC ID and subnet info

πŸ™Œ Final Thoughts

This project helped me go from beginner to builder.
If you’re learning Terraform, I recommend:
Start with small, real projects like this
Focus on understanding IAM + monitoring + VPC basics
Always document what you build (even your mistakes!)

I’m a junior cloud engineer sharing my journey.
πŸ”— GitHub: https://github.com/Salma22C/SalmaMohamedKassem
πŸ”— LinkedIn: www.linkedin.com/in/salma-mohamed-kassem

Top comments (0)