You are currently viewing Create A Public Subnet

Create A Public Subnet

Create a public subnet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet

In the last blog post, we have created a private subnet and explicitly associated it with a custom route table.

https://cloudaffaire.com/create-a-custom-route-table/

In this blog post, we are going to convert our private subnet (subnet 2) into a public subnet by allocation a public IP address and an Internet gateway. I am dividing this in two parts and in the first part we will allocate a public IP address and DNS hostname to an EC2 instance in this subnet. And in the next blog will create the internet gateway and enable internet access. Below is the configuration diagram for this demo.

Create A Public Subnet

Create a public subnet:

Step 1: Login to AWS console and navigate to ‘VPC’.

Create A Public Subnet

Step 2: Navigate to ‘Subnets’ and select the new subnet (subnet 2).

Create A Public Subnet

Note: Auto-assign public IPv4 is disabled for this subnet. We will enable auto assign public IPv4 so that any new instance created in this subnet can get a new public IPv4 address. You can also use Elastic IP address instead for the public address that will be persistent.

Step 3: Click ‘Modify auto-assign IP settings’ located under ‘Actions’.

Create A Public Subnet

Step 4: Check ‘Auto-assign IPv4’ and click ‘Save’.

Create A Public Subnet

Next, create an EC2 instance using this VPC and subnet (subnet 2)

Create A Public Subnet

Create A Public Subnet

Observe: A new public IPv4 address has been assigned to your new EC2 instance. But the Public DNS field is empty. If you create your VPC manually then only DNS resolution is enabled, and DNS hostname is disabled. If instead, you had created, you VPC using Launch VPC wizard both settings would have been enabled.

Next, we are going to enable DNS hostname for our VPC.

Step 5: Navigate to ‘Your VPCs’ and select your VPC. From ‘Actions’ click ‘Edit DNS hostnames’.

Create A Public Subnet

Step 6: Check ‘DNS hostnames’ and click ‘Save’.

Create A Public Subnet

A success message will be displayed. Click ‘Close’.

Create A Public Subnet

DNS hostnames successfully enabled for your VPC.

Create A Public Subnet

Your instance will also get a new Public DNS automatically.

Create A Public Subnet

But if we ping our EC2 instance using this public DNS or try to connect to it. It will fail because no internet gateway is associated with our VPC yet.

Cleanup: Delete your EC2 instance and then navigate to ‘Your VPCs’, select your VPC and from action click ‘Delete’.

Create A Public Subnet

Note: We will use this same VPC and existing configuration in upcoming blogs, hence if you wish to continue then don’t delete your VPC.

Hope you have enjoyed this blog post. In the next blog post, we are going to create an Internet Gateway and attach it to this VPC.

To get more details on VPC, please refer below AWS documentation

https://docs.aws.amazon.com/vpc/index.html

 

This Post Has One Comment

  1. Avatar
    swei

    What was the point of this post, if the final result was still “request timed out”?

Leave a Reply