AWS Day 3: Unveiling the Power of EC2 Instances
Harnessing Scalable Computing with Amazon EC2
Table of contents
- 1. What is EC2?
- 2. Why Do We Need AWS EC2?
- 3. What are the Types of EC2 Instances?
- 4. What is the Region and Availability Zone in EC2?
- Your First AWS Project: Deploying Jenkins on an EC2 Instance
Welcome to Day 3 of your AWS adventure! By now, you've gained insights into AWS's essential components like IAM. Today, we're diving into one of AWS's fundamental services: Elastic Compute Cloud (EC2). In this blog post, we'll explore what EC2 is, why it's essential, the different types of EC2 instances, and the concepts of regions and availability zones.
1. What is EC2?
Amazon Elastic Compute Cloud (EC2) is at the heart of AWS's cloud computing capabilities. In essence, it's a web service that provides resizable computing capacity in the cloud. Think of it as virtual machines (VMs) in the cloud that you can configure and use according to your needs.
EC2 instances come in various sizes and configurations, allowing you to run a wide range of applications, from simple web servers to complex data processing workloads.
2. Why Do We Need AWS EC2?
EC2 offers several compelling reasons to choose it as your computing resource in the cloud:
Scalability: EC2 instances can be scaled up or down based on your requirements, ensuring you have the right amount of computing power at all times.
Cost-Effectiveness: You only pay for the computing capacity you use, which can result in significant cost savings compared to maintaining physical hardware.
Flexibility: EC2 instances can be customized with various operating systems, applications, and configurations, giving you the flexibility to run diverse workloads.
High Availability: AWS provides features like Auto Scaling and Load Balancing, which help maintain high availability and fault tolerance for your applications.
Global Reach: You can launch EC2 instances in multiple AWS regions worldwide, bringing your applications closer to your users for reduced latency.
3. What are the Types of EC2 Instances?
EC2 instances come in a variety of types, each optimized for specific use cases. These types are categorized based on their performance characteristics:
General Purpose (M-Series): Suitable for a wide range of applications, including web servers and small to medium-sized databases.
Compute Optimized (C-Series): Designed for CPU-intensive workloads, such as data analytics and scientific computing.
Memory Optimized (R-Series): Ideal for memory-intensive tasks like in-memory databases and big data analytics.
Storage Optimized (I-Series): Tailored for storage-intensive workloads, such as NoSQL databases and data warehousing.
Accelerated Computing (P-Series and G-Series): Equipped with specialized hardware for tasks like machine learning, 3D rendering, and scientific simulations.
4. What is the Region and Availability Zone in EC2?
In the context of EC2, a region is a geographical area where AWS has data centers. Each region consists of multiple availability zones. An availability zone (AZ) is essentially a data center or a cluster of data centers in a region. EC2 instances can be launched in specific availability zones within a region.
The concept of regions and availability zones is crucial for ensuring high availability and redundancy. By deploying resources across multiple availability zones in a region, you can enhance fault tolerance and protect your applications against failures in a single data center.
Your First AWS Project: Deploy a simple web application(such as Jenkins) on the ec2 instance and access the application from outside AWS.
Your First AWS Project: Deploying Jenkins on an EC2 Instance
Congratulations on your AWS journey! In this hands-on guide, we'll walk you through deploying a simple web application, Jenkins, on an EC2 instance and accessing it from outside AWS. Jenkins is a widely used automation server that streamlines the software development process. Let's get started:
AWS Account: Make sure you have an AWS account. If you don't have one, you can sign up on the AWS website.
EC2 Key Pair: Create an EC2 key pair to securely access your EC2 instance. You can create one in the AWS Management Console under the "Key Pairs" section.
Step 1: Launch an EC2 Instance
Go to the AWS Management Console and navigate to the EC2 service.
Click on "Launch Instance."
Choose an Amazon Machine Image (AMI). I am using here Ubuntu server.
Select an instance type. For Jenkins, a t2.micro (free tier eligible) instance should suffice. Click "Next: Configure Instance Details."
Configure instance details as needed. Ensure that your instance has a public IP address or is launched in a public subnet so that it can be accessed from the internet.
Add storage, tags, and configure security groups to allow SSH (port 22) and HTTP (port 80) traffic. Review and launch the instance.
Select your key pair (the one you created in prerequisites) and launch the instance.
Step 2: Connect to Your EC2 Instance
Once your instance is running, select it in the EC2 dashboard.
Click "Connect" to see instructions on how to connect to your instance. You'll use SSH to access the instance.
ssh -i your-key-pair.pem ec2-user@your-instance-public-ip
Step 3: Install Jenkins
Connect to your EC2 instance using SSH as mentioned above.
Use the Jenkins installation Guide https://docs.google.com/document/d/1xXvQt0sDoZHdcgC24OwT2c2IuXhZ0iIM8zqmneZGRNg/edit
Update your instance and install Java, a prerequisite for Jenkins.
sudo apt update -y
sudo apt install openjdk-11-jre -y
- Download and install Jenkins.
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y
- Start and enable Jenkins service.
sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins
Step 4: Access Jenkins from Outside of AWS
To access Jenkins, open a web browser and enter your EC2 instance's public IP address followed by port 8080.
Retrieve the Jenkins initial admin password from your EC2 instance.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Paste the password into the Jenkins web page.
Follow the setup wizard to complete the Jenkins installation.
Once Jenkins is set up, you can start creating and managing your CI/CD pipelines.
Congratulations! You've successfully deployed Jenkins on an EC2 instance in AWS and accessed it from outside AWS. This is just the beginning of your AWS journey. Continue exploring AWS services and building more projects to enhance your skills.
In conclusion, AWS EC2 is a cornerstone of cloud computing, providing flexible and scalable computing resources to meet your diverse application needs. Whether you're running a small website or a complex data analysis pipeline, EC2 offers the right tools for the job. Understanding the types of instances and the significance of regions and availability zones will empower you to make informed decisions as you continue your AWS journey.
Stay tuned for more AWS insights, tutorials, and hands-on experiences. Happy AWS Day 3, and may your EC2 instances run smoothly in the cloud!
Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.
Did you find this article valuable?
Support CHANDRESH PATLE by becoming a sponsor. Any amount is appreciated!