DEV Community

Cover image for Configuring an Amazon VPC
John
John

Posted on

Configuring an Amazon VPC

A VPC(virtual private cloud) is an isolated portion of the AWS Cloud. You provision a VPC so that you can deploy AWS infrastructure services. It is a virtual network and, as such, it supports multiple subnets, routing, and fine-grained security mechanisms.

When you create a VPC, you define its IP address range, subnets, and route tables. You can also optionally use network gateways or hardware VPN solutions to securely connect it to on-premises corporate networks.

Inside this virtual network, you can deploy AWS computing resources. These resources include, for example, Amazon Elastic Compute Cloud (Amazon EC2) or Amazon Relational Database Service (Amazon RDS) instances. You can also define how—and whether—your private network space connects to endpoints in your network topology. A VPC can span multiple Availability Zones.

creating a vpc

key component Of A VPC

  • Subnet–Subnets are logical network segments within your VPC. They enable you to subdivide your VPC network into smaller networks inside a single Availability Zone. A subnet is publicif it is attached to an internet gateway, or privateif it is not.

  • Security group –A security group is a set of firewallrules that secure instances. They allow or block inbound and outbound traffic into an instance (stateful).

  • Primary network interface (elastic network interface) –An elastic network interface is a virtual network interface (NIC) that connects an instance to a network.

  • Router–A router is a component that routes traffic within the VPC.

  • Internet gateway –An internet gateway is a VPC component that enables communication between instances in a VPC and the internet.

  • Virtual private gateway –A virtual private gateway is the component that is defined on the AWS side of a virtual private network(VPN) connection.

  • Customer gateway –A customer gateway is a physical device or software application that is defined on the client side of a VPN connection

HOW TO CONFIGURE AWS VPC

Task 1: Creating a VPC

On the AWS Management Console, in the Search bar, enter and choose VPC to go to the VPC Management Console.

In the left navigation pane, for Virtual private cloud, choose Your VPCs.

Image description
In every Region, a default VPC with a Classless Inter-Domain Routing (CIDR) block of 172.31.0.0/16 has already been created for you. Even if you haven't created anything in your account yet, you will see some pre-existing VPC resources already there.

Choose Create VPC and configure the following options:

Resources to create: Choose VPC only.

Name tag: Enter Lab VPC.

IPv4 CIDR block: Choose IPv4 CIDR manual input.

IPv4 CIDR: Enter 10.0.0.0/16.

IPv6 CIDR block: Choose No IPv6 CIDR block.

Tenancy: Choose Default.

Tags: Leave the suggested tags as is.

Choose Create VPC.

creating a vpc

creating a vpc

At the top of the page, a message displays similar to the following: "You successfully created vpc-NNNNNNNNNNN / Lab VPC."

Choose Actions, and choose Edit VPC settings.

In the DNS settings section, select Enable DNS hostnames.

Choose Save.

EC2 instances launched into the VPC now automatically receive a public IPv4 Domain Name System (DNS) hostname.

Image description

Image description

Task 2: Creating subnets

Task 2.1: Creating a public subnet

In the left navigation pane, for Virtual private cloud, choose Subnets.

Image description

Choose Create subnet and configure the following options:

Image description

VPC ID: Choose Lab VPC.

Subnet name: Enter Public Subnet.

Availability Zone: Choose the first Availability Zone in the list. Do not choose No preference.

IPv4 CIDR block: Enter 10.0.0.0/24.

Choose Create subnet.

Image description

You now configure the public subnet to automatically assign a public IP address for all EC2 instances that are launched within it.

Select Public Subnet.

Image description

Choose Actions, and then choose Edit subnet settings.

In the Auto-assign IP settings section, select Enable auto-assign public IPv4 address.

Choose Save.

Image description

Even though this subnet has been named Public Subnet, it is not yet public. A public subnet must have an internet gateway, which you attach in a task later in the lab.

Top comments (0)