Configuring VPC settings

In the previous section, we configured the RAM and CPU of our EC2 instance. In this section, we will learn how to create a new VPC and Subnet for our EC2 instance.

Once we have selected t2.micro as our instance type, we are presented with the Configure Instance Details page:

In this section, we will see how we can configure the following options:

  • Number of Instances: This is left for the reader to decide how many instances are to be launched. For this chapter, we are launching one instance only.
  • Network: We will take a look at how to create a new VPC for our EC2 resources.
  • Subnet: We will look at separating our EC2 resources into different subnets within a VPC.
  • Auto-assign Public IP: We will enable this so that we can access it from our machine.

Let's start by creating a VPC:

  1. By clicking on the Create new VPC link, we are taken to the VPC Dashboard, where we can see existing VPCs and create new ones:

  1. Click on Create VPC and name it New VPC.

We already have a VPC network with IPv4 block 172.31.0.0/16. Let's proceed and create a new VPC with IPv4 block 10.0.0.0/16. As is mentioned in the dialogue box that appears, our IPv4 CIDR block size can only be between /16 and /28.

  1. Hit Yes, Create, and your VPC will be created within seconds:

To launch our EC2 instance in this VPC, we will have to create a subnet. Let's go to the Subnets section and create a subnet within our new VPC.

  1. Click on Create subnet and give it a name, New Subnet. We'll select the VPC we created. Upon selecting New VPC, the VPC CIDR block is shown in the display:

The user can choose any availability zone from those provided. However, we are keeping it as No Preference.

We are creating our subnet with the IPv4 CIDR block 10.0.1.0/24, which means it will give us a range of IPs from 10.0.1.1 to 10.0.1.254. However, we only have 251 IP addresses that can be used. This is because the 10.0.1.1 is reserved for the gateway of the subnet, 10.0.1.2 is reserved for AWS DNS, and 10.0.1.3 is reserved for any future use by AWS. 

  1. Once this is done, we select our VPC as our new VPC and select subnet | New Subnet. This is what your screen should look like:

6. Let's continue and add storage:

As we can see, each EC2 instance, while being launched, receives a root storage device by default. Each EC2 instance gets a default root storage by default. This is to house the OS files for the instance to launch. Other than that, we can add additional storage to the EC2 instance if required.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.47.221