AWS Cloud-Network lab

AWS Networking Lab - VPC Exploration

Overview

This lab will guide you through exploring the existing AWS networking infrastructure in your account. You’ll examine two VPCs with different configurations and understand key networking concepts like routing tables, subnets, and VPC endpoints.

Prerequisites

Your group identifier for this lab is “groupXY” where XY is your assigned group number.

Lab Objectives

By the end of this lab, you will have:


Part 1: Exploring the eks_vpc VPC

Step 1.1: Navigate to VPC Console and Visual Overview

  1. Log into AWS Console
  2. In the search bar, type “VPC”
  3. Click on “VPC” from the search results
  4. In the left sidebar, click “Your VPCs”
  5. Look for the VPC named “eks_vpc”
  6. Click on the VPC ID to select it
  7. In the left sidebar, click “Resource map”
  8. Study the visual representation of the VPC

Questions to consider:

Step 1.2: Examine VPC Details with CLI

Open your EC2 instance terminal (from the previous lab) and run:

# List all VPCs and find eks_vpc
aws ec2 describe-vpcs --query 'Vpcs[?Tags[?Key==`Name` && Value==`eks_vpc`]].[VpcId,CidrBlock,State]' --output table

# Get the VPC ID for eks_vpc (replace vpc-xxxxx with actual ID from above)
export EKS_VPC_ID=$(aws ec2 describe-vpcs --query 'Vpcs[?Tags[?Key==`Name` && Value==`eks_vpc`]].VpcId' --output text)

echo "EKS VPC ID: $EKS_VPC_ID"

Step 1.3: Investigate Subnets

# List subnets in eks_vpc
aws ec2 describe-subnets --filters "Name=vpc-id,Values=$EKS_VPC_ID" --query 'Subnets[*].[SubnetId,CidrBlock,AvailabilityZone,Tags[?Key==`Name`].Value|[0]]' --output table

Key observation: Note the CIDR block (10.0.0.0/16) and how subnets are distributed.

Step 1.4: Route Tables Analysis (The Tricky Part)

# List ALL route tables in the VPC
aws ec2 describe-route-tables --filters "Name=vpc-id,Values=$EKS_VPC_ID" --query 'RouteTables[*].[RouteTableId,Tags[?Key==`Name`].Value|[0],Associations[?Main==`true`]|length(@)]' --output table

Now let’s examine route table associations:

# Show detailed route table associations
aws ec2 describe-route-tables --filters "Name=vpc-id,Values=$EKS_VPC_ID" --query 'RouteTables[*].[RouteTableId,Associations[*].SubnetId,Associations[?Main==`true`]]' --output json

Trick Question Time:

  1. How many route tables do you see?
  2. Which route table shows “Main: true”?
  3. Are any subnets actually associated with the main route table?

Go back to the VPC Console and check:

  1. In the left sidebar, click “Route tables”
  2. Filter by your eks_vpc VPC
  3. Look at the “Subnet associations” tab for each route table

The Answer: The default/main route table exists but has no subnet associations. All subnets are explicitly associated with custom route tables.


Part 2: Exploring the nsrc-lab VPC

Step 2.1: Basic nsrc-lab VPC Information

# Get nsrc-lab VPC details
export NSRC_VPC_ID=$(aws ec2 describe-vpcs --query 'Vpcs[?Tags[?Key==`Name` && Value==`nsrc-lab`]].VpcId' --output text)

echo "NSRC Lab VPC ID: $NSRC_VPC_ID"

# Compare CIDR blocks
aws ec2 describe-vpcs --vpc-ids $EKS_VPC_ID $NSRC_VPC_ID --query 'Vpcs[*].[Tags[?Key==`Name`].Value|[0],CidrBlock]' --output table

Key observation: Note the different CIDR block (10.30.0.0/16).

Step 2.2: Find the Hidden S3 Endpoint

# Look for VPC endpoints in nsrc-lab
aws ec2 describe-vpc-endpoints --filters "Name=vpc-id,Values=$NSRC_VPC_ID" --query 'VpcEndpoints[*].[VpcEndpointId,ServiceName,VpcEndpointType,State]' --output table

Exploration Challenge:

  1. What service does this endpoint connect to?
  2. Why would you want an S3 endpoint in your VPC?

Let’s get more details:

# Get detailed endpoint information
aws ec2 describe-vpc-endpoints --filters "Name=vpc-id,Values=$NSRC_VPC_ID" --query 'VpcEndpoints[*].[VpcEndpointId,ServiceName,RouteTableIds,PolicyDocument]' --output json

Questions to consider:


Part 3: VPC Peering Theory Exercise

Step 3.1: CIDR Analysis for Peering

Let’s analyze if these VPCs can be peered:

EKS VPC: 10.0.0.0/16
NSRC Lab VPC: 10.30.0.0/16

Analysis Questions:

  1. Can you peer VPCs with overlapping CIDR blocks?
  2. Do 10.0.0.0/16 and 10.30.0.0/16 overlap?
  3. What would happen if both VPCs used 10.0.0.0/16?

Step 3.2: Theoretical Peering Steps

If you were to create a VPC peering connection between these VPCs, here are the steps you would follow:

  1. Create Peering Connection
  2. Accept Peering Connection
  3. Update Route Tables
  4. Security Group Rules

Final Questions:

  1. After peering, how would traffic from eks_vpc reach nsrc_lab?
  2. What would be the longest prefix match for traffic from 10.0.1.100 to 10.30.1.100?
  3. Why is the S3 endpoint only in one VPC and not the other?

Key Concepts Summary

VPC Architecture Patterns:

Route Table Insights:

VPC Peering Requirements:

Cost Optimization: