π 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)