0
0
AWScloud~10 mins

Creating a custom VPC in AWS - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating a custom VPC
Start
Define VPC CIDR
Create VPC
Create Subnets
Create Internet Gateway
Attach Internet Gateway to VPC
Create Route Table
Add Route to Internet Gateway
Associate Route Table with Subnets
End: Custom VPC Ready
The flow shows the steps to create a custom VPC: define IP range, create VPC, add subnets, set up internet gateway, route table, and associate them.
Execution Sample
AWS
aws ec2 create-vpc --cidr-block 10.0.0.0/16
aws ec2 create-subnet --vpc-id vpc-1234 --cidr-block 10.0.1.0/24
aws ec2 create-internet-gateway
aws ec2 attach-internet-gateway --vpc-id vpc-1234 --internet-gateway-id igw-1234
aws ec2 create-route-table --vpc-id vpc-1234
aws ec2 create-route --route-table-id rtb-1234 --destination-cidr-block 0.0.0.0/0 --gateway-id igw-1234
aws ec2 associate-route-table --subnet-id subnet-1234 --route-table-id rtb-1234
This sequence creates a VPC with a subnet, internet gateway, route table, and connects them for internet access.
Process Table
StepActionResource Created/ModifiedID/ValueState After Action
1Create VPC with CIDR 10.0.0.0/16VPCvpc-1234VPC vpc-1234 created with CIDR 10.0.0.0/16
2Create Subnet in VPC vpc-1234 with CIDR 10.0.1.0/24Subnetsubnet-1234Subnet subnet-1234 created in vpc-1234
3Create Internet GatewayInternet Gatewayigw-1234Internet Gateway igw-1234 created
4Attach Internet Gateway igw-1234 to VPC vpc-1234Attachmentigw-1234 attachedInternet Gateway attached to VPC
5Create Route Table in VPC vpc-1234Route Tablertb-1234Route Table rtb-1234 created
6Create Route 0.0.0.0/0 via igw-1234 in rtb-1234Routeroute-1Route to internet added in route table
7Associate Route Table rtb-1234 with Subnet subnet-1234Associationassoc-1Subnet uses route table with internet access
8EndN/AN/ACustom VPC setup complete with internet access
💡 All resources created and connected; VPC is ready for use with internet access.
Status Tracker
ResourceInitialAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7Final
VPCNonevpc-1234 (CIDR 10.0.0.0/16)vpc-1234vpc-1234vpc-1234vpc-1234vpc-1234vpc-1234vpc-1234
SubnetNoneNonesubnet-1234 (CIDR 10.0.1.0/24)subnet-1234subnet-1234subnet-1234subnet-1234subnet-1234 (associated)subnet-1234 (associated)
Internet GatewayNoneNoneNoneigw-1234igw-1234 attachedigw-1234 attachedigw-1234 attachedigw-1234 attachedigw-1234 attached
Route TableNoneNoneNoneNonertb-1234rtb-1234 with routertb-1234 with routertb-1234 with routertb-1234 with route
Key Moments - 3 Insights
Why do we need to attach the Internet Gateway to the VPC after creating it?
Creating the Internet Gateway alone does not connect it to the VPC. Step 4 attaches it, enabling internet traffic routing as shown in execution_table row 4.
What happens if we don't associate the route table with the subnet?
Without association (step 7), the subnet won't use the route table with internet access, so instances can't reach the internet. See execution_table row 7 for association importance.
Why define CIDR blocks when creating VPC and subnet?
CIDR blocks define IP address ranges. The VPC CIDR (step 1) is large, and subnet CIDR (step 2) is a smaller part inside it, ensuring organized IP allocation.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. What resource is created?
ARoute Table rtb-1234
BSubnet subnet-1234
CInternet Gateway igw-1234
DVPC vpc-1234
💡 Hint
Check the 'Resource Created/Modified' column at step 3 in execution_table.
At which step does the subnet get associated with the route table?
AStep 7
BStep 6
CStep 5
DStep 4
💡 Hint
Look for 'Associate Route Table' action in execution_table rows.
If the Internet Gateway was not attached to the VPC, what would be the state of internet access?
AInternet access would work normally
BInternet access would fail because IGW is not attached
CSubnet would have internet access without IGW
DRoute table would automatically fix it
💡 Hint
Refer to key_moments explanation about attaching IGW and execution_table step 4.
Concept Snapshot
Creating a custom VPC:
- Define a CIDR block (IP range) for the VPC
- Create the VPC resource
- Create subnets inside the VPC with smaller CIDRs
- Create and attach an Internet Gateway for internet access
- Create a route table and add a route to the IGW
- Associate the route table with subnets
- Result: VPC with internet connectivity ready for instances
Full Transcript
To create a custom VPC, start by defining the IP address range using a CIDR block. Then create the VPC resource with this CIDR. Next, create one or more subnets inside the VPC, each with a smaller CIDR block. Create an Internet Gateway and attach it to the VPC to enable internet access. Create a route table for the VPC and add a route that sends all internet traffic (0.0.0.0/0) to the Internet Gateway. Finally, associate this route table with the subnets so that instances inside can use it. This setup allows instances in the subnet to communicate with the internet through the VPC.