How to Create a VPC in AWS?

Sanoj
9 min readSep 24, 2023

--

Before creating VPC lets understand few concepts that should we know while creating the VPC below image is the representation of that concept

Hierarchy View of VPC

Explaination of the above “Architecture view of a created VPC:

├── AWS Account
│ ├── Region
│ │ ├── VPC (Virtual Private Cloud)
│ │ │ ├── Availability Zones or Subnets (Responsible for Providing resources, e.g., IP addresses)s.

  • 1. First, You have an AWS Account.
  • 2. Inside the AWS Account, you select a specific AWS Region.
  • 3. Within the chosen Region, you create a VPC (Virtual Private Cloud).
  • 4. Within the VPC, you configure Availability Zones or Subnets.
  • 5. These Availability Zones or Subnets are responsible for providing resources, such as IP addresses, within your VPC.

Keys points that you need to do during creation of VPC

1.Create Your VPC and Define IP Address Range (Pool):

  • When setting up your VPC, the first step is to establish its boundaries and assign an IP address range, often referred to as a “pool” (e.g., 172.31.0.0/16).
  • It’s important to note that at least one VPC is required per AWS region; you can’t work without it.

2. Subdivide Your IP Range into Subnets:

  • Within your VPC, you can further divide your IP address range into smaller segments called subnets.
  • Subnet sizes are based on your specific needs, determining how many IP addresses are available within each subnet.
  • Keep in mind that VPCs are regional, while subnets are tied to specific availability zones.

3. Create Routing Tables (Optional):

  • By default, AWS sets up a routing table when you create a VPC.
  • However, if you have specific routing requirements, you can create your own custom routing table.

4. Set Up an Internet Gateway (IGW):

  • Think of the Internet Gateway (IGW) as the gateway that connects your VPC to the wider internet; it acts as an access point.

5. Configure Routing Table with IGW and Subnet:

  • To enable internet access for your resources within the VPC, you’ll need to add the IGW and relevant subnets to your routing table.

6. Enable Public IP Configuration for Subnet:

  • To allow your instances to have public IP addresses, make sure to enable public IP configuration on the desired subnets.

7. Enable DNS Hostname Resolution for VPC:

  • Enabling DNS hostname resolution at the VPC level is crucial for certain AWS resources like EFS and RDS.
  • This setting ensures that resources that rely on DNS hostnames can function properly within your VPC.

Importent points when you create a subnet each subnet reserve 5 IP address
Thats why the first assignedable IP address to your host start with 10.0.0.5 if we assume 10.0.0.0/24 is my subnet range.

The first four IP addresses and the last IP address in each subnet CIDR block are not available for your use, and they cannot be assigned to a resource, such as an EC2 instance. For example, in a subnet with CIDR block 10.0.0.0/24, the following five IP addresses are reserved:

  • 10.0.0.0: Network address.
  • 10.0.0.1: Reserved by AWS for the VPC router.
  • 10.0.0.2: Reserved by AWS. The IP address of the DNS server is the base of the VPC network range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. We also reserve the base of each subnet range plus two for all CIDR blocks in the VPC.
  • 10.0.0.3: Reserved by AWS for future use.
  • 10.0.0.255: Network broadcast address. We do not support broadcast in a VPC, therefore we reserve this address.

By following these steps, you’ll establish a well-configured VPC that can effectively connect your AWS resources to the internet and each other, meeting your specific network requirements.

Now Lets look into the practicle Way how we can achive this:-

Step 1: Logging into your AWS Account, then navigate to the “Search Bar” where you should enter “VPC” and press the Enter key. For Reference below is the screenshot of the interface how you can navigate to VPC Console.

Step 1.1: Click either the “Create VPC” button or “Your VPC” on the left-side pane.

If you clicked on the Orange color button “Create VPC” you will get following screen.

If you clicked on the “Your VPC” you will get following screen.

If you took the option above option, just click on the “Create VPC” following screen will appear.

Step 1.2: Now give your VPC name and your custom CIDR(Classless Inter Domain Routing) Range as I have given both parameters as you can see in below image.

Step 1.3: After filling the CIDR range and VPC Name select your Tenancy “Default” or “Dedicated” by default it is selected as Default, after selecting the Tenancy click on the “Create VPC.”

Now you are thinking what’s the difference between “Default” and “Dedicated” Tenancy.

Here is the answer:

Default Tenancy:

. Shared Hardware: When you launch instances in a VPC with the default tenancy, they run on physical hardware that is shared with other AWS customers. This is sometimes referred to as “shared tenancy.”

. Cost-Efficient: Default tenancy is cost-effective because you are sharing the costs of the underlying hardware with other AWS customers. This is suitable for most workloads unless you have specific regulatory or compliance requirements.

. No Control Over Placement: You don’t have control over the physical placement of your instances, as AWS manages the hardware and makes decisions based on resource availability and optimization.

Dedicated Tenancy:

. Isolated Hardware: When you opt for dedicated tenancy, your instances run on physical hardware that is exclusively dedicated to your AWS account. This means that the hardware is not shared with other AWS customers.

. Regulatory Compliance: Dedicated tenancy is often chosen when there are strict regulatory or compliance requirements, such as in the healthcare or financial industries, where you need to ensure that your instances are physically isolated.

. Control Over Placement: With dedicated tenancy, you have more control over where your instances are placed, which can be useful for achieving specific performance or isolation goals.

. Higher Cost: Dedicated tenancy is more expensive than default tenancy because you are paying for the exclusive use of hardware resources.

After Click on the “Create VPC” following screen will appear.

Step 2: Click on the “Subnets” in the left-side pane, after that the following screen will appear.

Step 2.1: Click on the orange button “Create Subnet” After that following screen will appear.

Step 2.2: After selecting the “VPC ID” do the following things:

  • Choose your custom “VPC ID” from the dropdown menu.
  • Provide a subnet name.
  • Select the desired Availability Zone (AZ) for the subnet.
  • Fill in the subnet range.
  • Click on “Create Subnet.”

For reference following are the screen shot of the steps.

After clicking on the “Create subnet” Following screen will appear.

Step 3: Now create Route Table for that click on the “Route Tables” that is present on the left side window pane, after click on the “Route Tables” following screen will appear.

Step 3.1:

  • Click on the orange “Create route table” button.
  • Provide a name for the route table.
  • Select the VPC for which you want to create the route table.
  • Click the “Create route table” button.

For Reference following are the screenshot of the steps:

After clicking on the “Create route table” following screen will appear.

Step 4:

  • Click on “Internet gateways.”
  • Click the orange “Create Internet Gateway” button.
  • Provide a name for the Internet gateway.
  • Click on the “Create Internet Gateway” button.

For reference following are the screenshot of the steps:

After clicking on the “Create Internet Gateway” button following screen will appear.

Step 4.1:

  • Click on the “Attach to a VPC” button in white.
  • Alternatively, click on the “Action” button, then select “Attach to VPC.”
  • Choose your VPC from the list.
  • Click on the “Attach Internet Gateway” button.

Following are the screenshot of the above steps for reference:

After clicking on the “Attach internet gateway” following screen will appear.

Step 5: Configure the Route table with Internet gateway and subnet.

  • Go to “Route Tables.”
  • Select your desired route table.
  • Click on the “Routes” tab.
  • Click “Edit Routes.”
  • Click “Add Route.”
  • Enter the destination IP address CIDR value (e.g., 0.0.0.0/0) to communicate with any IP address or use CIDR range 0.0.0.0/0 for internet access.
  • Select the target as “Internet Gateway.”
  • Click “Save Changes.”
  • Click “ Subnet associations”
  • Click “Edit subnet associations”
  • Click on subnet “check box”
  • Click on “Save Associations”

Following are the screenshots of the above steps for your reference:

Steps 6: Enable Public IP Configuration for Subnet

  • Click on “Subnets” in the left-side window.
  • Select your desired subnet.
  • Click on “Actions.”
  • Choose “Edit Subnet Settings.”
  • Check the box for “Enable auto assign public IPv4 address.”
  • Click “Save.”

Following are the screenshots of the above steps for the reference:

Step 7: Enable DNS Hostname Resolution for VPC

  • Click on “Your VPC.”
  • Select your VPC.
  • Click on “Actions.”
  • Choose “Edit VPC Settings.”
  • Check the box for “Enable DNS hostnames.”
  • Click “Save.”

Following are the screenshot of above steps for reference:

By following these steps, you’ll have successfully created a secure and tailored Virtual Private Cloud (VPC) in AWS, providing a robust foundation for your cloud-based applications and services. Happy cloud computing!”

--

--