===== EC2 ===== => Ec2 means Elastic Compute Cloud => It is used create virtual machines in aws cloud. => EC2 is a paid service in aws cloud. => Ec2 VMs bill will be generated on hourly basis. => Ec2 VM minimum billing period is 1 hour. 9:00 AM ---> 9:15 AM ===> 1 hour 10:00 AM --> 10:15 AM ---> 1 hour 10:20 AM --> 10:30 AM ---> 1 hour Note: For practice purpose AWS provided "t2.micro/t3.micro" instances 1 year free of cost (monthly 750 hours we can use) Usecases : 1) To deploy dynamic web apps 2) To setup sonarqube server 3) To setup docker server 4) to setup Kubernetes cluster 5) To setup Jenkins server 6) To setup Nexus/Jfrog server ==================== How to setup EC2 vm ==================== => To setup EC2 instance we will use below options. 1) AMI 2) Instance Type 3) Keypair (public key & Private key) 4) Network (VPC) 5) Security Group (inbound & outbound) 6) Storage (EBS) ================================== How to connect with EC2 Linux VM =================================== => To connect with EC2 Linux vm we can use below SSH client softwares 1) Git Bash : only CLI operations 2) PuTTY : only CLI operations 3) MobaXterm : GUI & CLI Operations 4) WinSCP : only GUI operations =================== EC2 Video Tutorials ========== EC2 VM with MobaXterm : https://youtu.be/uI2iDk8iTps?si=28U-zc-uUfqfe9U5 EC2 VM with putty : https://youtu.be/GXc_bxmP0AA?si=dFiFuqPeVXVPJvSx EC2 VM with GitBash : https://youtu.be/JMlQaTXvw5o?si=V2EiOl7byTixEFd5 EC2 vm with static website hosting : https://youtu.be/681U88GlIWU?si=c4GGchABtLkMMMu9 Deploy SpringBoot app in EC2 linux VM : https://youtu.be/cRQPgbwOWq0?si=Ux9Y3AY-ZTbmMmEr ======================================== Static website hosting using EC2 VM ======================================== => Website means collection of web pages => Websites are divided into 2 types 1) static website 2) dynamic website => static website provides same response for every user. => Dynamic website provides response based on user login. => To deploy static websites we need a webserver. Ex: httpd, apache2, nginx.... => To deploy dynamic website we need a webserver like below Ex: Tomcat, IIS... ============================================= Hosting static website using amazon linux vm ============================================= Step-1 : Create EC2 VM with amazon linux ami Step-2 : Connect with EC2 VM using SSH Client (ex: gitbash) Step-3 : Install "HTTPD" webserver to run static websites Step-4 : Setup web pages (html files) Step-5 : Enable http protocol with 80 port number in Security Group inbound rules. Step-6 : Access website using EC2 VM public ip in our browser. ------------------------------------- sudo su yum install httpd -y service httpd start cd /var/www/html vi index.html ------------------------------------- Website URL : http://public-ip/ -------------------------------------- ======================= What is Load Balancer ======================= => When we run our application in single server then we have to face below challenges 1) One server should handle all reqs 2) Burden will increase on server 3) Response will be delayed for clients 4) Server can crash 5) Single Point Of Failure 6) Business Loss => To avoid above problems, we will run our application using "Load Balancer". => Load Balancer is used to distribute load to multiple servers in round robbin fashion. => We have below advantages with Load Balancer 1) App will run in multiple severs 2) Load will be distributed 3) Burden will be reduces on servers 4) Fast Performance 5) High Availability => We have 4 types of load balancers in aws 1) Application Load Balancer 2) Network Load balancer 3) Gateway Load Balancer 4) Classic Load balancer (previous generation) ======================= Load Balancer Lab Task ======================= #### Step-1) Create EC2 VM-1 with below user data #! /bin/bash sudo su yum install httpd -y cd /var/www/html echo "

Life Insurance Server - 1

" > index.html service httpd start #### Step-2) Create EC2 VM-2 with below user data #! /bin/bash sudo su yum install httpd -y cd /var/www/html echo "

Life Insurance Server - 2

" > index.html service httpd start ### Step-3) Add these 2 instances to one "Target Group" ### Step-4) Create Load Balancer with Target Group (ALB) Schme : Internet Facing select target group we have created ### Step-5) Access our aplication using LBR DNS URL