DEV Community

Cover image for Beginner's Guide to AWS: Creating Your First Virtual Private Cloud (VPC)
Syed Mustafa Hassan
Syed Mustafa Hassan

Posted on

Beginner's Guide to AWS: Creating Your First Virtual Private Cloud (VPC)

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:

Components of AWS VPC:

- 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.

5 Reasons to Use Amazon VPC:

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!

Step 1: Navigate to the VPC Dashboard
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

Step 2: Create a VPC
Click on "Create VPC" to initiate the VPC creation wizard. Provide the following details:

Image description

  • 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

Image description

Click "Create" to create your VPC.

Step 3: Configure Subnets
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

Select your "VPC".

Image description

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

Image description

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

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

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

Image description

Click "Create subnet."

Step 4: Set Up Internet Connectivity
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

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

Image description

Now you have to Attach to a VPC click on "Action" from dropdown select "Attach to a VPC"

Image description

Here select your VPC and click on "Attach internet gateway".

Image description

Step 5: Define Route Tables
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

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

Image description

Here your Route Table is created now click on "Edit Route".

Image description

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

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

select those subnets and click on "Save Associations".

Image description

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

Step 6: Configure Security Groups and NACLs
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

  • 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

Image description

Image description

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

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

Image description

  • 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

Image description

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!πŸŒŸπŸš€

Top comments (0)