Our requirement is to create VPC and two private instances with auto scaling to show work of two web servers as shown in below figure
There are some steps to complete this project
STEP 1:
- Go to aws console and sign-in to aws account
- Choose the vpc through search bar
Note: If we choose (vpc only) option then we have to create components step by step manually
STEP 2:
- Create one vpc
- Create four subnets as two public subnets and two private subnets for private subnets choose two different availability zones
- Create one public route table and two private route tables
- Update the subnet associations as (public subnets to public routes) and (private subnets to private routes)
- Create one internet gateway and attach to public route tables
- Create one NAT gateway and attach to private route tables
Note: If we choose (vpc and more) option and select the components as our requirements then it will create the connections automatically
- You can see all the component connections in preview
- As shown in below figure
STEP 3:
-
Go to EC2 service from vpc
-
Select the launch templates
-
Create the launch templates and give the name for launch template
-
Choose the instance type as free tire as shown in below figure
-
Select the created key pair or generate a new key pair
-
Update the network settings by clicking on edit option
• No need to change subnet
• Click on create security group
• enter the security group name
• enter the description it’s your choice
• select the created vpc for the project
• update the inbound rules
• one is ssh and another is http port 80
• launch the templats
• do this as shown in below figure
STEP 4:
-
Go to auto scalling group
-
Create the auto scalling group
-
Give the name for auto scalling group
-
Select the created launch templats
-
Choose instance type requirement
• Choose VCPUs minimum and maximum
• (2 is minimum) and (3 is maximum)
• Choose memory minimum and maximum
• (4 is minimum) and (8 is maximum)
• Select as shown in below figure
-
Select created vpc
-
Select 2 private availability zones as shown in below figure
-
No need to select load balancer leave as no load balancer
-
Choose desired capacity and scalling option as shown in below figure
-
Auto scalling group is created
STEP 5:
-
Go to instance
-
Check the instance their 2 private instances are created from auto scalling group
-
Give the name for 2 private instances as private 1 and private 2 to avoid confusions
-
Create one public instance named as bastion host as shown in figure
-
From that public instance we can connect the private through ssh client
-
completing the terminal work for two private instances
STEP 6:
-
Go to target groups
-
Create the target group
-
Give the name for target group
-
Select the two private instances as shown in below figure
-
Click on include as pending below
-
Click on create the target group then target group is created
STEP 7:
-
Go to load balancer
-
Click on create load balancer
-
Give the name for load balancer
-
Update network mapping
• Choose created vpc
• Choose two availability zones as shown in figure
-
Update the created security group as shown in below figure
-
Click on create load balancer then load balancer is created
-
Copy the load balancer DNS name to access the two web servers
STEP 8:
-
Go to Google page or new web page
-
Paste the copied DNS name on URL path
-
You can see the two created web servers as shown in figure
-
Just re-fresh the page then you see second server
That’s it, our requirement is done.