EC2: Elastic Compute Cloud
- AWS Budget Setup
- Root User: Billing and Cost Management > Account > Billing and Payments > IAM user and role access to Billing information: ✅ Activate IAM Access > Update
- IAM User:
- Billing and Cost Management > Bills > Charges by service
- Billing and Cost Management > Free Tier
- Billing and Cost Management > Budgets > Create Budget
- Choose budget type: Use a template (Simplified)
- Template: Zero Spend Budget
- Budget Name: My zero-spend budget
- Email Recipients: mohammedimransharif@proton.me
- Create Budget
EC2: Elastic Compute Cloud
- EC2 Basics
- Amazon EC2:
- EC2 = Elastic Compute Cloud = Infrastructure as a Service
- Capabilities:
- Renting virtual machines (EC2)
- Storing data on virtual drives (EBS)
- Distributing load across machines (ELB)
- Scaling services with Auto Scaling Groups (ASG)
- EC2 Sizing & Configuration Options:
- Operating System (OS): Linux, Windows, or macOS
- CPU: Compute power and number of cores
- RAM: Memory allocation
- Storage Options:
- Network-attached: EBS and EFS
- Local hardware: EC2 Instance Store
- Network: Speed, public IP address
- Security: Firewall rules via security groups
- Bootstrap script: EC2 User Data
- EC2 User Data:
- You can bootstrap instances using EC2 User Data scripts.
- Bootstrapping: Running commands at first launch
- Runs only once on initial startup
- Automates boot-time tasks like:
- Installing updates
- Installing software
- Downloading files
- Custom initialization
- Runs as the root user
- EC2 Instance Types:
| Instance | vCPU | Mem (GiB) | Storage | Network Performance | EBS Bandwidth |
|---|---|---|---|---|---|
| t2.micro | 1 | 1 | EBS-Only | Low to Moderate | — |
| t2.xlarge | 4 | 16 | EBS-Only | Moderate | — |
| c5d.4xlarge | 16 | 32 | 1 × 400 NVMe SSD | Up to 10 Gbps | 4750 |
| r5.16xlarge | 64 | 512 | EBS-Only | 20 Gbps | 13600 |
| m5.8xlarge | 32 | 128 | EBS-Only | 10 Gbps | 6800 |
Hands-On: Create an EC2 Instance with User Data for a Simple Website
- Launch an EC2 Instance running Linux
- We'll create our first virtual server using the AWS Console.
- This helps us understand the parameters involved in launching an instance.
- We'll automate setup using EC2 User Data for web server configuration.
- We'll also learn how to start, stop, and terminate the instance.
- Steps:
- EC2 > Instances > Launch an instance
- Name:
My First Instance - Key Pair: Create New > Name:
EC2 tutorial> Download - Network Settings: ✅ Allow HTTP traffic from the internet
- User Data (bootstrap script):
#!/bin/bash # use this for your user data (script from top to bottom) # install httpd (Linux 2 version) yum update -y yum install -y httpd systemctl start httpd systemctl enable httpd echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html- Click Launch Instance
- Go to: EC2 > Instances > ✅ Select your instance
- View Public IPv4 address > Open in browser using
http:// - Note: Public IP changes on reboot; Private IP remains constant.
EC2 Instance Types Basics
- Overview: Choose EC2 instances optimized for different use cases.
Ref: aws.amazon.com/ec2/instance-types - General Purpose
- Great for diverse workloads such as web servers or code repositories.
- Balanced compute, memory, and networking resources.
t2.microis commonly used in tutorials and free-tier setups.
- Compute Optimized
- Ideal for compute-intensive tasks that require high-performance processors:
- Batch processing workloads
- Media transcoding
- High-performance web servers
- High-performance computing (HPC)
- Scientific modeling & machine learning
- Dedicated gaming servers
- Example:
C8g
- Memory Optimized
- Best for workloads that process large datasets in memory.
- Use cases:
- Relational/non-relational databases
- Distributed cache stores
- In-memory BI databases
- Real-time big data processing
- Examples:
R7g, R7i, R7iz
- Accelerated Computing – Uses hardware accelerators like GPUs for ML, AI, and graphics workloads.
- Storage Optimized
- Optimized for high, sequential read/write access to local storage.
- Use cases:
- OLTP systems
- Relational & NoSQL databases
- In-memory cache (e.g., Redis)
- Data warehousing applications
- Distributed file systems
- Example:
i8g
- Instance Features – Naming convention:
m: instance class5: generation2xlarge: size within the class
- To compare instances across families and specs, visit ec2instances.info
Security Groups & Classic Ports Overview
- Introduction to Security Groups
- Fundamental component of AWS network security
- Control how traffic is allowed into/out of EC2 instances
- Contain only allow rules
- Rules can reference IP addresses or other security groups
- Security Groups – Deeper Dive
- Act as a virtual firewall at the EC2 level
- Regulate:
- Port access
- IP ranges (IPv4 and IPv6)
- Inbound traffic (external → instance)
- Outbound traffic (instance → external)
- Security Groups – Good to Know
- Can be attached to multiple instances
- Scoped to a region/VPC pair
- If traffic is blocked, the EC2 instance won't detect it
- Best practice: Use a separate security group for SSH
- If the app times out → likely security group issue
- If the app gives “connection refused” → app issue or not running
- All inbound traffic is blocked by default
- All outbound traffic is allowed by default
- Common Ports
22– SSH (Linux login)21– FTP (upload files)22– SFTP (secure file upload)80– HTTP (unsecured websites)443– HTTPS (secured websites)3389– RDP (Windows login)
- Security Groups – Hands-On
- Go to: EC2 > Network & Security > Security Groups
- Select security group > Configure Inbound/Outbound rules
- Add, remove, or modify rules as needed
- SSH Overview
No comments:
Post a Comment