AWS EC2 Services

🖥️ Amazon EC2 (Elastic Compute Cloud)

Amazon EC2 provides scalable compute capacity in the AWS cloud. It allows you to launch virtual servers on demand and pay for what you use.


🔹 Key Concepts

1. EC2 Instance Types

  • General Purpose (e.g., t3, t4g, m5)
  • Compute Optimized (c5)
  • Memory Optimized (r5, x1)
  • Storage Optimized (i3, d2)
  • Accelerated Computing (p4, inf1)

2. Instance Lifecycle

  • Start → Running → Stop → Terminate
  • Instance retirement and status checks

3. Key EC2 Components

  • AMI (Amazon Machine Image) – OS and application environment
  • Instance Type – Hardware configuration
  • Security Group – Acts as a virtual firewall
  • Key Pair – SSH access credentials
  • Elastic IP – Static public IP address
  • User Data – Shell script to run on first boot (cloud-init)

4. Storage Options

  • EBS (Elastic Block Store)
  • Instance Store (ephemeral)
  • EFS for network-attached storage

5. Networking

  • Public/Private Subnets
  • Elastic IPs
  • NAT Gateways
  • Security Groups vs NACLs

🛠️ Hands-On Task List

TaskDescription
✅ Launch an EC2 InstanceUse AWS Console or CLI to launch a t2.micro instance with Amazon Linux 2023.
✅ Configure Security GroupAllow SSH (port 22) and HTTP (port 80).
✅ SSH into EC2Connect using a PEM key from a Linux/Mac terminal or PuTTY for Windows.
✅ Install a Web ServerUse sudo yum install httpd -y and start the service.
✅ Add a Custom Index PageModify /var/www/html/index.html with your own content.
✅ Use EC2 User DataLaunch a new instance that automatically installs a web server using user data.
✅ Create AMICreate a custom AMI from your configured instance.
✅ Attach/Detach EBS VolumeAttach an additional EBS volume and mount it inside the instance.
✅ Stop, Start, and TerminateObserve instance state behavior and test persistent storage.
✅ Enable Detailed MonitoringTurn on CloudWatch detailed monitoring and view CPU graphs.

📘 Exam Tips

  • Know the difference between EBS and Instance Store.
  • Understand user data vs metadata (http://169.254.169.254).
  • Security groups are stateful, NACLs are stateless.
  • EC2 instances by default do not have public IPs in private subnets.
  • IAM roles are used to assign permissions to instances without hardcoding credentials.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html

Tasks to do

  • ✅ Change the existing ssh public key