Today, we will be test the aws knowledge on services in AWS, as part of the 90 Days of DevOps Challenge.
Task-1
Launch an EC2 instance using the AWS Management Console and connect to it using SSH.
📚Step1: Sign in to the AWS Management Console at console.aws.amazon.com.
📚Step2: Open the EC2 Dashboard , Navigate to EC2 service
-
📚Step3: Click on the "Launch Instance" button to start the instance creation
📚Step4: Choose an Amazon Machine Image , Instance Type, Keypair
📚Step5: Configure the instance details, such as VPC, subnet, storage details and security group settings.
Create a new security group or select an existing one. Make sure to allow inbound SSH traffic (port 22) to connect via SSH
Configure the storage requirements for your instance. By default, an EBS volume will be attached to the instance for the root device.
📚Step6: Review Instance Launch
Review your configuration settings. If everything looks good, click on "Launch Instance " to proceed.
Successfully created EC2-instance
📚Step7: Connect to EC2 Instance:
Once the instance is started running, connect to it using SSH from your local machine.
Here's how:
In the EC2 Dashboard, select your instance from the list.
Click on the "Connect" button at the top of the page.
In the "Connect to your instance" section, you will see the SSH command to connect to your instance.
📚Step8: Open your preferred terminal or SSH client and run the SSH command.
Make sure to replace
/path/to/keypair.pem
it with the actual path to your private key file and<Public-IP-or-DNS>
with your instance's public IP address or public DNS name.If prompted, confirm connecting by typing "yes."
You should now be connected to your EC2 instance via SSH.
You have successfully launched an EC2 instance using the AWS Management Console and connected to it using SSH.
Install a web server on the EC2 instance and deploy a simple web application.
🔑Step1: Update the package manager on the EC2 instance
Install the Apache Web Server on the EC2 instance
Check whether Apache Web Server installed or not , later use the command to start the webserver.
sudo apt update -y sudo apt install -y apache2 sudo systemctl status apache2 sudo systemctl start apache2
🔑Step2: Verify that the web server is running by accessing your instance's public IP address in a web browser. You should see the default page of the web server.
🔑Step3: Deploy a Simple Web Application:
Edit the index.html file using vi or nano editor
Insert the basic web page html css code into index file
Navigate to the document root directory:
cd /var/www/html/
Create or upload your HTML or web application files to this directory.
Once your files are updated, you can access your web application by entering your instance's public IP address in a web browser. You should see your deployed web application.
Monitor EC2 Instance with Amazon CloudWatch and troubleshoot any issues that arise.:
🔎Step1: Go to the AWS CloudWatch service in the AWS Management Console.
🔎Step2: In the CloudWatch console, navigate to the "Metrics" section in the navigation pane.
🔎Step3: select the metrics you want to monitor for your EC2 instance.
Some commonly monitored metrics include CPU utilization, network traffic, diskusage, and memory usage. Choose the metrics based on your monitoring needs.
🔎Step4: Click on the "Create Alarm" button and configure the alarm settings based on your requirements.
This includes setting thresholds, specifying the period, and defining actions to be taken when the alarm state is triggered.
For example, you can set a CPU utilization threshold of 80% and configure CloudWatch to send a notification or trigger an auto-scaling action if the threshold is breached.
🔎Step5: Once you have configured the alarm settings, click on the "Create Alarm" button to create the alarm.
CloudWatch will now start monitoring the selected metrics for your EC2 instance based on the configured alarm. If any issues arise, such as high CPU utilization or low disk space, CloudWatch will trigger the alarm and perform the defined actions.
To troubleshoot any issues identified by CloudWatch, you can take the following steps:
When troubleshooting issues identified by CloudWatch, you can follow these steps:
Identify the Issue: Start by reviewing the CloudWatch alarm or metric that alerted you to the problem. Understand the nature of the issue, whether it's related to application performance, infrastructure, or other areas.
Gather Information: Collect relevant information about the issue. This may include CloudWatch logs, metrics, and any error messages or stack traces associated with the problem. Use the CloudWatch console or API to retrieve this data.
Analyze Logs and Metrics: Review the logs and metrics in CloudWatch to gain insights into the problem. Look for any patterns, anomalies, or errors that can help you understand the root cause.
Determine Scope and Impact: Assess the scope and impact of the issue. Is it affecting a single instance or multiple instances? Are there any associated performance degradations or errors? Understanding the scope will help you prioritize your troubleshooting efforts.
Check Resource Configuration: Verify the configuration of the affected resources, such as EC2 instances, load balancers, or databases. Ensure that the settings are correct and aligned with your requirements.
Review CloudWatch Alarms: Examine the CloudWatch alarms that are associated with the affected resources. Check if the alarm thresholds are set appropriately and if any actions are triggered based on the alarm state. Adjust the alarms if necessary.
Look for Related Events: Investigate any related events that occurred around the time of the issue. This includes events within the AWS environment, such as changes to security groups, network configurations, or deployments.
Utilize CloudWatch Insights: Leverage CloudWatch Insights to perform ad-hoc queries on your logs and identify potential patterns or correlations. Insights can help you narrow down the scope and identify specific log entries related to the problem.
Collaborate with Teams: If the issue extends beyond your expertise, involve relevant teams or stakeholders. This might include developers, system administrators, or AWS support. Collaboration can help pool knowledge and perspectives to solve the problem more effectively.
Implement Remediation Steps: Based on your analysis, implement appropriate remediation steps to address the issue. These steps might involve adjusting resource configurations, scaling instances, optimizing code, or applying patches or updates.
Monitor and Validate: After implementing the remediation steps, monitor the affected resources using CloudWatch. Validate that the issue has been resolved and ensure that the system remains stable over time.
Task-2
Create an Auto Scaling group using the AWS Management Console and configure it to launch EC2 instances in response to changes in demand.
📌Step1: Create template from instance
📌Step2: Create an Auto Scaling Group (ASG) using the AWS Management Console:
Log in to your AWS Management Console.
Navigate to the Auto Scaling service.
Create a new Auto Scaling group.
Configure the launch template or configuration for the instances in the group.
Set up the scaling policies, including minimum and maximum instances.
Choose Launch template and create a name for your Auto Scaling group.
Select VPC and Availability Zones and subnets.
Configure advanced options to make it as default.
Now, Configure group size , scaling policies , Desired Capacity, Minimum and Maximum Capacity.
Review your configuration settings. If everything looks good, click "Create Auto Scaling group" to create the group.
Auto-scaling group is now created.
Use Amazon CloudWatch to monitor the performance of the Auto Scaling group and the EC2 instances and troubleshoot any issues that arise
📌Step3: To monitor the performance of your Auto Scaling group and EC2 instances using Amazon CloudWatch and troubleshoot any issues, you can follow these steps:
- Sign in to the AWS Management Console at console.aws.amazon.com.
📌Step4: Open the CloudWatch service in the AWS Management Console
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 the auto-scaling group that we created, Click on the "Monitoring" tab and enable "Auto scaling group metric"
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
📌Step5: To view the state of the Auto Scaling group and the EC2 instances using the AWS Command Line Interface (CLI) and verify the number of instances running, you can use the following AWS CLI commands:
Install and configure the AWS CLI on your local machine.
sudo apt-get install awscli aws configure aws ec2 describe-instances
To check the state of the auto-scaling group.
aws autoscaling describe-auto-scaling-groups
Remember that involving AWS Support is particularly useful for complex or critical issues that require advanced troubleshooting expertise. Troubleshooting steps may vary depending on the specific issue and your environment. It's essential to adapt these steps to your context and leverage additional AWS documentation and resources as needed.
Thank you for 📖reading my blog, 👍Like it and share it 🔄 with your friends.