- The application that needs to access the internet for any info like json or api info's
- It is better if we mask the application ip address when sending a request HERE NAT GATEWAY WILL BE USED.
- Ex: EC2 instance trying to access the info from the internet now NAT GATEWAY will change the IP ADDRESS to public subnet of NAT and it sends the request So that your ip address or other data will be hidden
- If the application or anything that you want to access on the internet is hacked. BUT THEY don't know the ip address of the application
- Ex: You want to deploy your application in 2 availability zones, Instead of creating EC2 instances 2 times
- WE CAN SAY AUTO SCALING GROUP, CREATE MINIMUM OF 2 REPLICAS INCASE MY APPLICATION RECEIVES MORE REQUESTS 2 SERVERS ARE NOT ENOUGH TO LOAD TO ACCEPT THE INCOMING TRAFFIC. ASG will Immediately take a decision to SCALE UP TO 4 servers or 5 .. and more.
- It will balance the load, Let say we have 100 requests, we have 2 servers SO LOAD BALANCER WILL SENDS THE REQUESTS like 50 requests to one and 50 to other server
- Apart from this we can also do path based routing, host based routing
- The EC2 instances that we have created are in private subnet, they don't have public ip or we can not SSH into this instances directly
- We want to keep them secured, we dont create any public ips, but we will create a BASTION HOST
- Though that BASTION HOST or Jump Server we will connect to the ec2 instances
- Their will proper loggin machanism if we use BASTION HOST, We can configure rules and lot of other things.
NOTE: DOC REF : https://docs.aws.amazon.com/vpc/latest/userguide/vpc-example-private-subnets-nat.html
Create VPC
- Select VPC and more if we select VPC only then we have to create lot of configurations like ipv4 v6 subnets and etc,Better to CREATE with VPC and MORE
- Check preview
- select NAT gatways as 1 per AZ
- vpc ENDPOINT AS NONE
- IT is nothing but IP address which will remain same even if you GO DOWN THEN the INSTANCE
- It is like STATIC IP ADDRESS
- Select EC2 instance --> from the left panel select Auto scaling groups --> create auto scaling group
- It can not be created directly we have to use Template as a reference -->
- Rest of the settings are same, The port will be as per application best practise is only allow required ports.
NOTE: ALL the options are same only mentioned should changed
- select any name
- select create luanch template
- select vpc that you have created
- select availablity zones as per diagram app should be in private subnet so select 2 private subnets as per diagram
- Group size as per we need 2 increate to 2 and max to 4 as required based on the requirement
- Now 2 instances are created by they dont have public ip addresses
- We have to create BASTION HOST IT works as mediatory from private instances and outiside to access the instances
- copy the key using scp from to bastion host
- from bastion host access the private instance using ssh
ssh -i devops-key1.pem [email protected]
bastion hostssh -i devops-key1.pem [email protected]
private instance which have only private ippython3 -m http.server 8000
used to run python server for testing
NOTE: It is Layer 7 Load Balancer which does HTTP AND HTTPS (APPLICATION LOAD BALANCER) it
- Go to EC2 instance on the left panel find load balancer
- It should be in public subnet
- Select application load balancer -->
NOTE: WE HAVE TO DEFINE WHICH INSTANCES SHOULD BE ACCESSABLE