Beginner's Guide to AWS: Creating Your First Virtual Private Cloud (VPC)
Published: 2024-04-19 21:07:58

Welcome to this beginner-friendly guide to Amazon Web Services (AWS). In this tutorial, we'll walk you through the process of creating your first Virtual Private Cloud (VPC) on AWS. A VPC allows you to launch AWS resources into a virtual network that you define, providing you with control over your network environment, including IP address range, subnets, routing tables, and network gateways. Let's get started on your journey into AWS VPC!

AWS VPC serves as a logical extension of your on-premises data center into the cloud, offering unparalleled control and flexibility over your cloud network infrastructure. Let's delve into the core components and concepts that underpin AWS VPC:

## <u>Components of AWS VPC:</u>

**- Subnets:**
 Subnets are segments of the VPC's IP address range where you can place groups of resources. They are associated with specific availability zones, providing fault tolerance and high availability.

**- Route Tables:**
 Route tables dictate the traffic flow within the VPC. They contain rules, known as routes, that determine where network traffic is directed, whether to other instances within the VPC, to the internet via an internet gateway, or through a virtual private gateway to an on-premises network.

**- Internet Gateway:**
 An internet gateway facilitates communication between instances within the VPC and the internet. It serves as a gateway for outbound traffic and a target for inbound traffic destined for public-facing resources.

**- NAT Gateway:**
 Network Address Translation (NAT) gateway allows instances in private subnets to initiate outbound traffic to the internet while preventing inbound traffic from initiating connections with those instances.

**- Elastic IP Addresses:**
 Elastic IP addresses are static IPv4 addresses designed for dynamic cloud computing. They are associated with your AWS account and can be dynamically remapped to different instances.

**- Security Groups:**
 Security groups act as virtual firewalls for your instances, controlling inbound and outbound traffic. You can define rules that allow specific types of traffic based on protocol, port, and source/destination IP address.

**- Network Access Control Lists (NACLs):**
 NACLs are stateless, numbered sets of rules that act as a firewall at the subnet level. They control traffic entering and exiting subnets by allowing or denying traffic based on IP addresses, protocols, and ports.

## <u>5 Reasons to Use Amazon VPC:</u>

**1. Enhanced Security:**
 With AWS VPC, you can create isolated sections of the AWS Cloud, ensuring that your resources are securely contained within your virtual network. You can implement security groups and network access control lists (NACLs) to control inbound and outbound traffic.

**2. Custom Networking:**
 AWS VPC enables you to design a network topology that meets your specific requirements. You can define your IP address range, create subnets across multiple availability zones, and configure routing tables to control traffic flow.

**3. Scalability:**
 As your infrastructure grows, AWS VPC scales with you. You can easily add or remove subnets, modify routing configurations, and expand your IP address range to accommodate your evolving needs.

**4. Integration with AWS Services:**
 VPC seamlessly integrates with other AWS services, allowing you to connect your VPC to resources such as Amazon EC2 instances, Amazon RDS databases, and AWS Lambda functions securely.

**5. Hybrid Cloud Connectivity:**
 AWS VPC provides options for connecting your on-premises infrastructure to the AWS Cloud, enabling hybrid cloud architectures. You can establish VPN connections or use AWS Direct Connect to extend your corporate network into the cloud.

Now, let’s walk you through the process of Creating AWS virtual private cloud. _Let's begin!_

**<u>Step 1: Navigate to the VPC Dashboard</u>**
Navigate to the AWS Management Console by visiting https://console.aws.amazon.com/. Sign in with your AWS credentials and search for “VPC”:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0iaugp13vaz3w0z2ah0.PNG)

**<u>Step 2: Create a VPC</u>**
Click on "_Create VPC_" to initiate the VPC creation wizard. Provide the following details:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8lny5495af401l91bd6d.PNG)

- **Name Tag:** Assign a descriptive name to your VPC.
- **IPv4 CIDR Block:** Define the IPv4 address range for your VPC, ensuring it does not overlap with other networks.
- **IPv6 CIDR Block:** Optionally, specify an IPv6 CIDR block.
- **Tenancy:** Choose between default or dedicated tenancy based on your requirements.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c76i5ftfj6attem727h.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sp0ib9c9osh9291h6w02.PNG)

Click "_Create_" to create your VPC.

**<u>Step 3: Configure Subnets</u>**
Navigate to the "_Subnets_" section and click on "_Create subnet_." Specify the subnet details, including name, VPC, availability zone, and IPv4 CIDR block. Repeat this step to create additional subnets for different tiers of your application.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7rq9zcko4oy08r0oz0y.PNG)

Select your "VPC".
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eor1h8a7ks9zyfqo5w3v.PNG)

Here we are creating four different subnets in two different zone.
Follow these steps to create the required subnets:

**1. Create Subnet for Zone 2a (Public1):**

- Name: Public1
- VPC: Select the VPC created in Step 2.
- Availability Zone: Choose Zone 2a.
- IPv4 CIDR Block: Define the IPv4 CIDR block for this subnet.
- Leave IPv4 CIDR block blank or choose an appropriate value.
- Click "Add new subnet."
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdbu9nc5g85ogo9mdl2h.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sg2wy3ykj6msfkfus7k6.PNG)

**2. Create Subnet for Zone 2a (Private1):**

- Name: Private1
- VPC: Select the same VPC.
- Availability Zone: Choose Zone 2a.
- IPv4 CIDR Block: Define the IPv4 CIDR block for this subnet. It should be within the same address range as the public subnet but with a different range to denote it as a private subnet.
- Leave IPv4 CIDR block blank or choose an appropriate value.
- Click "Add new subnet."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kj2arzypwytf5lrrwyrb.PNG)

**3. Create Subnet for Zone 2b (Public2):**

- Name: Public2
- VPC: Select the same VPC.
- Availability Zone: Choose Zone 2b.
- IPv4 CIDR Block: Define the IPv4 CIDR block for this subnet.
- Leave IPv4 CIDR block blank or choose an appropriate value.
- Click "Add new subnet."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lepejozb8475zmdjgcgy.PNG)

**4. Create Subnet for Zone 2b (Private2):**

- Name: Private2
- VPC: Select the same VPC.
- Availability Zone: Choose Zone 2b.
- IPv4 CIDR Block: Define the IPv4 CIDR block for this subnet. It should be within the same address range as the public subnet but with a different range to denote it as a private subnet.
- Leave IPv4 CIDR block blank or choose an appropriate value.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7vg0r8sq2wdbr6ef49z.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8p70r6fdkunoivix0y3z.PNG)

Click "_Create subnet._"

**<u>Step 4: Set Up Internet Connectivity</u>**
If your resources require internet access, attach an internet gateway to your VPC. Create a new internet gateway, attach it to your VPC, and update the route table to route internet-bound traffic through the gateway.

Navigate to the "Internet Gateways" section and click on "Create Internet Gateways."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5e0kqxqs903k6vh5639z.PNG)

Name your internet gateway and click on "Create Internet Gateways."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/69ufpl9af8erz9dv0xnx.PNG)

Now you have to Attach to a VPC click on "_Action_" from dropdown select "_Attach to a VPC_"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iytvog4dxkucjpqyqeqd.PNG)

Here select your VPC and click on "_Attach internet gateway_".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tvbvkf9pzi0c97nc5y8.PNG)

**<u>Step 5: Define Route Tables</u>**
Create custom route tables to control the flow of traffic within your VPC. Associate the route tables with the appropriate subnets and define routes for local traffic and internet-bound traffic.

Navigate to the "Route Tables" section and click on "_Create Route Table._"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urdna5yinenomscs7mh5.PNG)

Give the name to your route table and select your VPC then click on "_Create Route Table._"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/boxlyz3pi33swl3j2pce.PNG)

Here your Route Table is created now click on "_Edit Route_".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ql0d1umdwdo6papllhie.PNG)

Then in "Edit Route" click "Add route" and select **_0.0.0.0/0_** as "_Destination_" select your created Internet Gateway in "_Target_" now click on "_Save Changes_".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/it005h9x0jy3io92rp7f.png)

From here will go to "_subnet associations_" to give the access of internet to your required subnets. So, for that click on "_Edit Subnet Associations_".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ldl7a1tp3cxfsa1ozfsn.PNG)

select those subnets and click on "_Save Associations_". 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oka16b05b71rnf0pcih7.PNG)

By doing this public subnets will use public route table which we created and private subnets will use default route table. 

**<u>Step 6: Configure Security Groups and NACLs</u>**
Define security groups to control inbound and outbound traffic to your instances based on port, protocol, and source/destination IP addresses. Configure network ACLs to provide an additional layer of security at the subnet level.

**Configure Security Groups:**

- First navigate to the "security groups" section and click on "_Create security group._"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1b1wuf65rh4y58sfyou9.PNG)

- Provide a name and description for the security group (e.g., "Public-SG").
- Select the VPC created in Step 2.
- Define inbound and outbound rules:
- Inbound: Allow traffic on necessary ports for your public instances (e.g., HTTP, HTTPS, SSH).
- Outbound: Allow all traffic (default outbound rule).
- Click "Create security group."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo72ttcy5bw5ou6x9g75.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxm1qp38a1dso13b38oq.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yj92ezohkta4swbb92fg.PNG)

**Configure Network Access Control Lists (NACLs): (Optional)**

- Go to the "Network ACLs" section in the VPC dashboard.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2oae6xtpmymexrs0d21i.PNG)

- Click on "Create network ACL."
- Provide a name and description for the NACL (e.g., "Public-NACL").
- Select the VPC created in Step 2.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obqgva5c2e728pp9gchr.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbhx3d7ul91hn6xtilmk.PNG)

Congratulations! You've successfully created your first Virtual Private Cloud (VPC) on AWS. Your VPC provides a secure and customizable network environment for deploying your AWS resources. As you continue your journey with AWS, explore more advanced networking concepts and features to optimize your infrastructure and enhance your cloud experience.

Remember to manage your VPC resources securely and follow AWS best practices for network security and compliance. With AWS VPC, you have the flexibility and control to build scalable and resilient cloud architectures tailored to your organization's needs.

## Conclusion

AWS Virtual Private Cloud (VPC) empowers organizations to design and deploy secure, isolated, and highly customizable network environments in the cloud. By mastering the creation and configuration of VPCs, businesses can architect cloud infrastructures that meet their specific requirements for scalability, security, and connectivity. Whether hosting simple web applications or complex enterprise workloads, AWS VPC provides the essential framework for building resilient and efficient cloud architectures. Embrace the power of AWS VPC and unlock endless possibilities in the realm of cloud computing.

Keep exploring, learning, and leveraging the power of cloud computing with AWS!🌟🚀