Part3: Deploying application in a VPC

Part3: Deploying application in a VPC

Accessing servers in a private subnet

·

2 min read

In today's blog, we shall learn how to access the instances in a Public subnet.

Since the servers are in the private subnet, we cannot directly reach to these. We will use a bastion host - this is a server that will be deployed in the public subnet. We can access the private subnet through this.

Let us first create an EC2 instance which will from now be referred to as Bastion host in the public subnet, SSH into this. Then from this server, we will be able to SSH and connect to the instances in the private subnet.

  1. Go to EC2 home page>Instances>Create Instance

  2. Name the instance, select the ami

  3. Scroll down>Select the instance type>Key pair

  4. Scroll furthermore, select the VPC that we created in the last blog > Be sure to select public subnet and enable auto assigning IP address since this EC2 shpuld be created in the Public subnet

  5. Next, create a security group that will allow ssh access to this instance and create on Launch Instance.

  6. Check if the instance is successfully launched

  7. Before logging in to this instance we shall first copy our pem file from our local to Bastion host as we will need this to further login to our private instances via the Bastion host

  8. We shall then login into the Bastion host and check if pem file has been copied

  9. The PEM file is successfully copied. Let us now check if we can log in to our instances in the public subnet through this server

    We have successfully logged into the instance in a private subnet, the same method can be followed to log into the instance in the public subnet as well. In the next blog, we shall learn how to deploy a simple Python server in these instances