Day 47: Test Knowledge on aws ??
Sayali Shewale
DevOps Engineer | AWS cloud Engineer | AWS DevOps | Linux | Docker | Jenkins | Terraform | Kubernetes | Ansible | Grafana
Task-01
Launch an EC2 instance using the AWS Management Console and connect to it using SSH.
Click on the "Launch Instance" button to start the instance creation process.
Select an Amazon Machine Image (AMI) to use for the instance.
Choose an instance type based on your needs and requirements.
Configure the instance details such as VPC, subnet, security groups, and storage. click on 'Launch instance'
Instance is created.
Click on the "Connect" button to view the connection details.
Connect to the instance using the SSH client of your choice
Install a web server on the EC2 instance and deploy a simple web application.
Once connected to the instance, update the package manager and install the web server (e.g. Apache, Nginx). here installed apache server using command.
sudo apt-get install apache2
Start apache service and check status of apache service.
Go inside directory /var/www/html.
Create a new index.html file which is simple html file contain simple form.
Browse public-ip which shows simple web application.
Monitor the EC2 instance using Amazon CloudWatch and troubleshoot any issues that arise.
Go to the Amazon CloudWatch dashboard.
Go to the Amazon EC2 console and select the instance you want to monitor.
Click on the "Monitoring" tab and enable "Detailed monitoring"
Go to the Amazon CloudWatch console and select the "Metrics" page.
Click on the "EC2" tab to view the available EC2 metrics.
Select the metric you want to monitor. For example, you can monitor CPU usage, memory usage, disk I/O, or network traffic. Click on "Pre-instance Metrics"
Configure the CloudWatch alarm for the selected metric.
Click on the "Create Alarm" button to set up an alarm.
Select the metric you want to monitor
Choose 'EC2'
Click on 'Pre-Instance Metrics'
Select the metric CPU utilization
Choose the condition that will trigger the alarm (e.g. when the CPU utilization is above a certain threshold for a certain amount of time).
below threshold limit is 50.
Set up additional alarm parameters such as name, description, and notification settings.
Click on 'Create alarm'
Alarm is created.
If an alarm is triggered, go to the CloudWatch dashboard to view the metrics and logs for the instance.
领英推荐
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.
First create a 'Launch Template' from ec2 instance.
Launch template is created.
Click on the "Create Auto Scaling group" button to start the creation process.
Select the launch template to use for the instances in the group.
Choose the instance type and other configuration details such as VPC, subnet, security groups, and storage.
Set up the scaling policies to determine when to launch new instances. configure desired, minimum and maximum capacity of instance.
Select 'Target tracking scaling policy' and choose 'metric type' to CPU utilization which will create an alarm.
Click on "Create auto scaling group"
Auto-scaling group is created.
Use Amazon CloudWatch to monitor the performance of the Auto Scaling group and the EC2 instances and troubleshoot any issues that arise.
Target tracking policy in autoscaling create 2 alarms with 2 different conditions.
Once the alarm is set up, it will start monitoring the specified metric for the Auto Scaling group. If the metric exceeds the threshold that you have set, the alarm will be triggered and take the action that you have specified.
Go to auto-scaling group that we created, Click on the "Monitoring" tab and enable "Auto scaling group metric"
You can also create alarm by going to CloudWatch dashboard.
Click on the "Create Alarm" button to set up an alarm.
Click on "EC2".
Click on 'By Auto Scaling Group'.
Choose the metric you want to monitor. You can search for the metric by name.
Select any metric which you want to monitor and create an alarm.
Once the alarm is created, it will start monitoring the specified metric and trigger the configured action if the conditions are met. You can view the status of the alarm in the CloudWatch console, and manage and update the alarm settings as needed.
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.
Install and configure the AWS CLI on your local machine.
Install aws cli using command
sudo apt-get install awsli
Configure AWS cli
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
There are 2 instances running which is launched by auto-scaling group because we choose desired capacity value is 2.
Use the below command to view the state of the EC2 instances launched by the Auto Scaling group.
aws ec2 describe-instances
Verify that the correct number of instances are running and that they are healthy and functioning properly.
Thank you for reading!