Wednesday, 17 July 2024

Configure a Virtual Private Cloud (VPC) with an Internet Gateway and subnets on AWS

Step 1: Select/Create VPC

1. Navigate to VPC Dashboard**:

   - Go to the AWS Management Console.

   - Open the VPC Dashboard.


2. Create a VPC**:

   - Click on "Create VPC".

   - **Name**: Give your VPC a name.

   - **IPv4 CIDR Block**: Enter `10.0.0.0/16` (provides 65,536 IP addresses).


Step 2: Create an Internet Gateway (IGW)

1. Create IGW**:

   - In the VPC Dashboard, go to "Internet Gateways".

   - Click on "Create Internet Gateway".

   - **Name**: Provide a name for the IGW.

   - Once created, it will be in a detached state.


2. Attach IGW to VPC**:

   - Select the newly created IGW.

   - Click on "Actions" and then "Attach to VPC".

   - Choose the VPC you created in Step 1.

Step 3: Create Subnets

1. Create Subnet:

   - In the VPC Dashboard, go to "Subnets".

   - Click on "Create Subnet".

   - **Name**: Provide a name for the subnet.

   - **VPC**: Select the VPC created in Step 1.

   - **Availability Zone**: Select an availability zone.

   - **IPv4 CIDR Block**: Enter `10.0.1.0/24` (provides 256 IP addresses).


2. Create Additional Subnets**:

   - Repeat the steps to create additional subnets as needed, using different CIDR blocks (e.g., `10.0.2.0/24`, `10.0.3.0/24`, etc.).

Step 4: Create a Route Table

1. Create Route Table**:

   - In the VPC Dashboard, go to "Route Tables".

   - Click on "Create Route Table".

   - **Name**: Provide a name for the route table.

   - **VPC**: Select the VPC created in Step 1.


2. Edit Routes**:

   - Select the newly created route table.

   - Go to the "Routes" tab and click on "Edit routes".

   - Add a new route:

     - **Destination**: `0.0.0.0/0`

     - **Target**: Select the Internet Gateway created in Step 2.


3. Edit Subnet Associations**:

   - Go to the "Subnet Associations" tab.

   - Click on "Edit subnet associations".

   - Select the subnets you want to associate with this route table.

Final Step: Verify Configuration

- Ensure that the IGW is attached to the VPC.

- Confirm that the subnets are associated with the route table.

- Verify the routes to ensure that `0.0.0.0/0` is correctly routed to the IGW.


You're done! Your VPC is now configured with an Internet Gateway and subnets, ready to use.