So In this project I am going to show like how we can host a secure server in AWS Cloud.
Step 1 {Architecture}
Firstly, let's see the architecture diagram below -
Step 2 {Overview}
So, we are going to create a VPC that you can use for your severs deployment. Then in the same VPC server we are going to deploy servers in two availability Zones, by using Auto Scaling Groups and an Application Load Balancer. For additional security, we are going to deploy our servers in private subnets. The servers receive requests through the load balancer. The servers can connect to the internet by using a NAT gateway. To improve resiliency, we deploy the NAT gateway in both Availability Zones.
Step 3 {Configuring VPC}
We named our VPC and create our VPC with 2 Availability Zones, then we add 2 private subnets , for NAT gateways we add "1 per AZ" so now we have a NAT gateway at each availability zone.
Step 4 {AutoScaling Groups}
Part 2
Step 5 {Bastion Host}
Next, we go to EC2 check our previous created 2 servers which are secure currently so to access those two secure servers I created a bastion host {ec2 server} within the same VPC and one of the public subnet through this we can access our private subnets.Then we just create our bastion host.
Step 6 {Added key name into our Bastion Host}
Now, through our SSH we loggined Bastion Host and using the command
scp -i "address of key name .pem" "address of key name .pem file" ec2-user@bastionpublicip:/home/ec2-user/home
so to access this home you firstly have to login into your bastion ip and make a folder name home then exceute the above command so that the say key name pair .pem file is no being added to your bastion host the reason to add this to your bastion host because using this .pem file you can access your private subnets which contain servers because they also have the same key name pair
Step 7 {Start server}
With the help of key pair present in bastion host you can access the private servers using their private IP address and you can now start a new server. For this I started an python server running on port 8000
Step 8 {Configuring Load Balancer}
Now, we are going to make a application load balancer, within the same VPC and in Public subnet (automatically it is looking for public subnet only), then we add our security groups after that we are going to make our target group where we choose instances , then add the port of 8000 because there our server is running then we deploy our load balancer.
Step 9 {Setup Complete}
Now you can run you application in Internet , even through you cannot directly access the server and make changes to it.
ScreenShots
Thank you
With Regards
sudoaptrana
If you have more improvements to this feel free to contribute in my github repo
https://github.com/geekaryan/SecuredVPC/blob/main/README.md