Today, we will be testing the AWS knowledge on services in AWS, as part of the 90 Days of DevOps Challenge.
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.
Steps -
- Launch an EC2 instance with SSH and HTTP ports open.
SSH to the Ubuntu machine and update using the command -
sudo apt update -y
Run the command sudo
apt-get install apache2 -y
to install a web server.Here, I'm using Tooplate template of a website(simple HTML code can also be used to launch a webserver)
wget https://www.tooplate.com/zip-templates/2137_barista_cafe.zip
sudo apt install unzip -y
unzip 2137_barista_cafe.zip
- The binaries are downloaded and unzipped
- Copy all template files to /var/www/html
sudo cp -r 2137_barista_cafe/* /var/www/html/
- Now, we can check if the website is hosted by accessing the public IP of the server
- The page is accessible and running fine
- Start monitoring the servers from the monitoring tab
- Enable detailed monitoring from Cloudwatch to set alarms for any actions.
- Now, we can set metrics in Cloudwatch and enable alerts for further monitoring.
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.
Steps -
- First of all, we will have to create a launch template using the EC2 machine
- Once the template is created, go to Auto Scaling Group and create an ASG using the template
- Select the required EC2 servers and create the ASG. Configure the desired, minimum, and maximum capacity of the instance.
- Select the Target tracking scaling policy and set a threshold.
- As soon as the ASG is set, we will see two new instances running as per the selected desired capacity.
- Go to Cloudwatch and we should have two alarms created(which we created while creating the ASG)
- Enable the Cloudwatch monitoring for metrics collection.
- Now, we need to validate the ASG from CLI, and install awscli using below command-
sudo apt-get install awscli
- Configure the AWS CLI
- Run the below command to check the ASG details from CLI -
aws autoscaling describe-auto-scaling-groups --region=us-east-1
- Run the below command to describe ec2 instances from CLI
aws ec2 describe-instances --region=us-east-1
- Here, we can see the alarm was triggered when the utilization crossed the threshold.
Thank you :)