Table of contents
- Task-01
- Task-02
- Create an Auto Scaling group using the AWS Management Console and configure it to launch EC2 instances in response to changes in demand.
- Use Amazon CloudWatch to monitor the performance of the Auto Scaling group and the EC2 instances and troubleshoot any issues that arise.
- Use the AWS CLI to view the state of the Auto Scaling group and the EC2 instances and verify that the correct number of instances are running.
Task-01
Launch an EC2 instance using the AWS Management Console and connect to it using SSH.
Install a web server on the EC2 instance and deploy a simple web application.
Monitor the EC2 instance using Amazon CloudWatch and troubleshoot any issues that arise.
Step 1:- Firstly we need to go to AWS console and need to launch EC2 machine
Now we need to connect to that machine using SSH key
Step 2:- Now we need to Install a web server on the EC2 instance and deploy a simple web application.
So for that we need to install apache2
sudo apt-get install apache2 -y
Using below command we can see the status of apache2
sudo systemctl status apache2
If we search with the ip address we can see the below deatils
if we need a csutom webesite we have to follow few steps
#chnage the directory
cd /var/www/html
# remove the exsiting index.html
sudo rm -f index.html
# create a new index.html and chnage the file permission
sudo touch index.html
# To change the file permission
sudo chmod 777 index.html
Now if we search same ip addres we can see the below ip address
Step 3:- Now we need to Monitor the EC2 instance using Amazon CloudWatch and troubleshoot any issues that arise.
Now if we go to aws console there we have monitoring tab and we can monitor the particular instances CPU Utilization ,Ststus check and so on..
if we need to use cloud watch then we need to cloud watch dashboard
First we need to go to in alarms and cick on create alarm
Now we have click on select matrix need to select EC2
Need to click on per instnace metrics
Need to select CPU utilization credit usage click on select metric
Need to give 50 and click on Next
Now give the meaningful name click on Next
After creating the alarm it will be like below so if there are any issues related EC2 CPU we can go and see the logs from cloud watch
Task-02
Create an Auto Scaling group using the AWS Management Console and configure it to launch EC2 instances in response to changes in demand.
Use Amazon CloudWatch to monitor the performance of the Auto Scaling group and the EC2 instances and troubleshoot any issues that arise.
Use the AWS CLI to view the state of the Auto Scaling group and the EC2 instances and verify that the correct number of instances are running.
Step 1:- Firstly we need to create a launch template before creating an autoscaling group
Step 2:- we need to create an autoscaling group
need to give the name and select launch template from the drop-down menu
we can select VPC and AZ
Here we can select max, min and desired capacity depending upon the requirement
Select 'Target tracking scaling policy' and choose 'metric type' for CPU utilization which will create a Cloud Watch Alarm.
Once review is completed we can go ahead and launch the EC2 machines
Once created we can see the below results
Now we can see the 2 instance is automatically launching with the help of autoscaling
Step 3:- We need to Use Amazon CloudWatch to monitor the performance of the Auto Scaling group and the EC2 instances and troubleshoot any issues that arise.
Now we can create cloud watch alarm
We are giving the condition as 80
We need to give the name and click on next
After creating the alarm it will be shown below
Step 4:- We need to use the AWS CLI to view the state of the Auto Scaling group and the EC2 instances and verify that the correct number of instances are running.
Firstly we need to install AWS CLI with that machine by running the below commands
sudo apt update
sudo apt-get install awscli -y
aws --version
Now we need to AWS configure by providing AWS Access Key ID, Secret Access Key, Region Name and Output Format.
Use the below command to view the state of the Auto Scaling group and the instances running in it.
aws autoscaling describe-auto-scaling-groups
Use the below command to view the state of the EC2 instances launched by the Auto Scaling group.
aws ec2 describe-instances
Thank you for reading!! I hope you find this article helpful!!
if any queries or corrections to be done to this blog please let me know.
Happy Learning!!
Saikat Mukherjee