Introduction to AWS Compute & EC2 β A Beginner's Guide

Table of contents
- π What is Compute in the Cloud?
- π§© Types of Compute Services in AWS
- π‘ What is Amazon EC2?
- πΈ EC2 Pricing Models
- π EC2 Best Practices
- π§ Launching an EC2 Instance (Step-by-Step)
- π Deploying a Web App to EC2
- π Assignment: Deploy & Secure a WebApp
- π§ͺ DevOps Assignment: Automate it All!
If you're stepping into the world of cloud computing, understanding Amazon EC2 (Elastic Compute Cloud) is essential. Whether you're a developer, DevOps engineer, or just AWS-curious, this guide walks you through compute services in AWS with a real-world approach.
π What is Compute in the Cloud?
"Compute" refers to the processing power required to run applications, services, and workloads in the cloud. It includes resources like CPU, RAM, storage, and networking. AWS offers several compute options for different needs:
π§© Types of Compute Services in AWS
EC2 β Scalable virtual servers (most commonly used)
Lambda β Serverless, event-driven compute
ECS/EKS β Container orchestration using Docker/Kubernetes
Lightsail β Simplified app hosting with GUI
Elastic Beanstalk β Easy deployment over EC2
Outposts β AWS hardware on-premises
Batch β Efficient batch job execution
π Use Case Example:
Choose EC2 for hosting a Spring Boot application; Lambda for running a script when a file is uploaded to S3.
π‘ What is Amazon EC2?
Amazon EC2 offers scalable virtual servers in the AWS cloud. It gives you root access, the ability to configure networking, storage, and full OS-level control.
Key EC2 Concepts:
Instance β A virtual server
AMI (Amazon Machine Image) β A pre-configured OS + app software template
Instance Type β Hardware configuration (e.g., t2.micro)
Key Pair β Used for secure SSH access
Security Group β Virtual firewall to control access
Elastic IP β A static IP address
πΈ EC2 Pricing Models
On-Demand β Pay per hour/second
Reserved Instances β Commit 1β3 years for cost savings
Spot Instances β Cheapest, but can be interrupted
Free Tier β 750 hours/month for
t2.micro
/t3.micro
for 12 months
π EC2 Best Practices
Use IAM roles instead of hardcoding credentials.
Tag resources for better management.
Restrict ports in Security Groupsβonly open what's needed.
Stop instances when not in use to avoid costs.
π§ Launching an EC2 Instance (Step-by-Step)
Log in to AWS Console > EC2 > Launch Instance
Select Amazon Linux 2 (Free Tier eligible)
Choose
t2.micro
(ort3.micro
)Add 8GB of storage
Configure security group to allow:
SSH (port 22)
HTTP (port 80)
Create and download your key pair (.pem file)
Launch the instance!
π Deploying a Web App to EC2
Install Java & Git on the instance:
sudo yum install git -y sudo yum install java-17-amazon-corretto -y
Clone your GitHub repo:
git clone https://github.com/yourname/spring-boot-app.git cd spring-boot-app java -jar demo-app.jar
Or transfer your app JAR using SCP:
scp -i your-key.pem app.jar ec2-user@<public-ip>:/home/ec2-user/
Access the app in your browser via EC2βs public IP on port 8080 or 80.
π Assignment: Deploy & Secure a WebApp
π§ Steps:
Launch EC2, install Java, Git
Upload Spring Boot app
Open necessary ports via Security Groups
Ensure app is reachable via REST endpoints
Harden security β block unused ports
Automatically shut down instance after a set time
π Bonus:
Make the JAR file a service so it runs in the background
Upload/Read files to/from S3 via REST APIs
π§ͺ DevOps Assignment: Automate it All!
Write a script that:
Provisions EC2
Installs dependencies
Clones and deploys the app
Opens required ports
Shuts down the instance after use
π Make the script configurable for:
Instance type
Dependencies
Repo URL
Subscribe to my newsletter
Read articles from TechEazy Consulting directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
