Lab 7: AWS VPC with Frontend and Backend

1. Create a VPC with One Public and One Private Subnet

1. Open AWS Console
2. Search for:
VPC

3. Open VPC Dashboard

4. Click:
Create VPC

5. Select:
VPC and more

6. Enter VPC name

Example:
MyVPC

7. IPv4 CIDR Block:
10.0.0.0/16

8. Number of Availability Zones:
1

9. Number of Public Subnets:
1

10. Number of Private Subnets:
1

11. Enable:
NAT Gateway

12. Click:
Create VPC

AWS automatically creates:
- VPC
- Public subnet
- Private subnet
- Route tables
- Internet Gateway


--------------------------------------------------

2. Launch a Frontend Instance in the Public Subnet

1. Go to:
EC2 Dashboard

2. Click:
Launch Instance

3. Enter instance name

Example:
Frontend-Server

4. Select:
Ubuntu Server

5. Select Instance Type:
t2.micro

6. Create or select key pair

7. Under Network Settings:
- Select created VPC
- Select Public Subnet
- Enable Auto-assign Public IP

8. Create security group:
Allow:
- SSH (22)
- HTTP (80)

9. Click:
Launch Instance


--------------------------------------------------

3. Launch a Backend Instance in the Private Subnet

1. Click:
Launch Instance

2. Enter instance name

Example:
Backend-Server

3. Select:
Ubuntu Server

4. Select:
t2.micro

5. Select same VPC

6. Select:
Private Subnet

7. Disable:
Auto-assign Public IP

8. Create security group:
Allow:
- SSH (optional)
- MySQL/Aurora (3306)

9. Click:
Launch Instance


--------------------------------------------------

4. Allow Frontend to Access Backend on DB Port

1. Go to:
EC2 Dashboard → Security Groups

2. Open backend instance security group

3. Open:
Inbound Rules

4. Click:
Edit inbound rules

5. Add Rule:

Type:
MySQL/Aurora

Port:
3306

Source:
Frontend instance security group

6. Click:
Save Rules

Now frontend instance can access backend instance on database port 3306.
