Part2: Deploying Application in a VPC

Part2: Deploying Application in a VPC

Creating servers in a Private subnet

·

3 min read

Since we have successfully created a VPC, today we shall look at the steps that are followed to create an EC2 server in a Private subnet.

We will be creating these servers via Launch templates. A launch template is needed to attach to an Auto-scaling group which makes sure the desired no of instances are always running.

We will be following the below steps to successfully launch an EC2 instance in a private subnet :

  1. We will first create a launch template

  2. Next, attach it to an autoscaling group that automatically scales instances based on traffic

  3. Moving on, we shall launch instances in a private subnet through the template that we just created.

Creating a launch template

  1. Search for EC2 in the search bar, once the EC2 homepage loads, click on the launch template on your left side

  2. Provide a name and a description for this server

  3. Scroll down and select the instance, ami and key pair.

  4. In the network settings, select the VPC that you created as per my previous blog.

  5. Create a new security group rule to allow port 22 for SSH access and 5000 for the application

  6. Click on "Create launch template"

Creating Auto-scaling group.

  1. Once the launch template is created, we shall move on to creating an auto scaling group.

  2. Go back to EC2 home page and select Auto scaling group on the right bottom of your screen

  3. Click on "Create auto-scaling group"

  4. Provide the auto scaling group name and select the launch template that we just created.

  5. In the next page, select the VPC in which we wish to launch the instance and the subnet. Be sure to select the Private subnet in both Availability Zones

  6. Click Next and there are no settings to be done on this page as we will be creating a load balancer separately

  7. Just click Next, and move on to the next page to configure group size and scaling

  8. Here, fill in the desired, max and minimum capacity

  9. Click on Next, skip the Notifications and tags page as we are not adding any.

  10. Land on the review page. Check for all the settings, scroll down and then click create scaling groups

  11. We can now check in the EC2 page if the desired no of instances are launched

We can see that 2 instances are created in the private subnet as per our requirement. The next step is to log in to these instances through a bastion server and deploy our server. Follow my next blog to do this