Extended version of A secure web portal with client-user interface.

Hello everyone,

In this blog , we are going to extend the previous task with a functionality of accessing private subnet using Bastionhost.

Previous Task link :

Our main agenda is :

Additional feature to be added to the previous Task , that is NAT Gateway to provide the internet access to instances running in the private subnet.

Performing the following steps:

1. Write an Infrastructure as code using terraform, which automatically create a VPC.

2. In that VPC we have to create 2 subnets:

1. public subnet [ Accessible for Public World! ]

2. private subnet [ Restricted for Public World! ]

3. Create a public facing internet gateway for connect our VPC/Network to the internet world and attach this gateway to our VPC.

4. Create a routing table for Internet gateway so that instance can connect to outside world, update and associate it with public subnet.

5. Create a NAT gateway for connect our VPC/Network to the internet world and attach this gateway to our VPC in the public network

6. Update the routing table of the private subnet, so that to access the internet it uses the nat gateway created in the public subnet

7. Launch an EC2 instance which has Wordpress setup already having the security group allowing port 80 sothat our client can connect to our wordpress site. Also attach the key to instance for further login into it.

8. Launch an EC2 instance which has MYSQL setup already with security group allowing port 3306 in private subnet so that our wordpress vm can connect with the same. Also attach the key with the same.

Architecture of our Agenda

Step 1 . Creating a secure web portal by following the link below :

Step 2. Adding the functionality of NAT Gateway to it.

Adding NAT Gateway

After this , we will again apply the complete code of terraform using “terraform apply -auto-approve” command.

terraform apply
apply complete

Output where we can see the nat gateway :

Added NAT Gateway

Step 3. Connecting to the instance in the private subnet using ssh, and can connect to the outer world or to the internet :

Can connect to the outer world.

Hence, we have successfully configured the NAT Gateway. Now we are able to connect to the internet even from the outside world.

Thank You!!!!

I am a tech enthusiast, researcher and work for integrations. I love to explore and learn about the new technologies and their right concepts from its core.