Skip to content

Izharn001/Terraform-Project-2-VPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Project 2 - VPC & EC2 Infrastructure

Overview

This project provisions a custom AWS network infrastructure using Terraform. It includes a VPC, public subnet, internet gateway, route table, and an EC2 instance deployed within the network.

The project demonstrates core Infrastructure as Code (IaC) concepts along with basic AWS networking.

Resources Created

  • AWS VPC
  • Public Subnet
  • Internet Gateway
  • Route Table & Association
  • Security Group
  • EC2 Instance

Architecture

This project provisions a custom AWS network setup:

  • A VPC (10.0.0.0/16)
  • A public subnet (10.0.1.0/24)
  • An Internet Gateway for outbound internet access
  • A route table directing traffic (0.0.0.0/0 → IGW)
  • A security group allowing SSH access
  • An EC2 instance deployed within the public subnet
  • EC2 instance uses dynamically retrieved latest Amazon Linux AMI

Skills Practiced

  • Terraform workflow (init, plan, apply, destroy)
  • Variables and outputs for reusable configurations
  • Resource creation and dependency management
  • AWS networking fundamentals (VPC, subnet, route tables, internet gateway)
  • Using data sources for dynamic resource configuration (latest AMI lookup)
  • Debugging infrastructure issues (VPC and security group mismatch)

How to run

  • terraform init
  • terraform validate
  • terraform plan
  • terraform apply

To destroy resources:

  • terraform destroy

Challenges & Fixes

Issue: Security group and subnet in different VPCs

  • EC2 failed to launch due to mismatch between subnet and security group

Fix:

  • Added vpc_id to security group: vpc_id = aws_vpc.main_vpc.id

Lesson Learned:

  • Security groups are tied to a specific VPC
  • All resources must belong to the same network

Improvements

  • Add key pair for SSH access
  • Refactor code into reusable modules
  • Add private subnet and NAT Gateway
  • Implement remote backend (S3 + DynamoDB)

About

Terraform project provisioning a custom AWS VPC, public subnet, and EC2 instance with dynamic AMI lookup.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages