AWS Compute Services — EC2, Lambda, Elastic Beanstalk, SAM
Amazon EC2 (Elastic Compute Cloud)
Section titled “Amazon EC2 (Elastic Compute Cloud)”EC2 is your foundational compute service on AWS. It gives you resizable compute capacity with full control over instance configuration, storage, networking, and security.
Instance Types
Section titled “Instance Types”Different instance types optimize for different workloads:
| Type | Family | Best For |
|---|---|---|
| General-purpose | t (burstable), m (standard) | Web apps, small databases, mixed workloads |
| Compute-optimized | c (high-performance) | Batch jobs, media transcoding, HPC |
| Memory-optimized | r (RAM-heavy), x (extreme) | In-memory databases, real-time analytics |
| Storage-optimized | i, d, h (I/O intensive) | NoSQL databases, data warehousing |
| Accelerated | p (GPU), f (FPGA) | ML training, graphics rendering |
The exam heavily tests instance types—know which family fits which use case.
Instance Lifecycle & Management
Section titled “Instance Lifecycle & Management”Instances go through states: launch → running → stop (reversible) → start → terminate (final). Stopping an instance preserves the EBS root volume, but terminated instances are gone forever. Auto Scaling automatically adjusts instance count based on demand or schedules.
Elastic Block Store (EBS)
Section titled “Elastic Block Store (EBS)”EBS provides persistent block storage attached to EC2 instances. Volume types include:
| Volume Type | Use Case | Durability |
|---|---|---|
| gp2/gp3 (SSD) | General workloads, databases | Highly durable |
| io1/io2 (IOPS SSD) | High-speed databases, I/O intensive | Very high IOPS |
| st1 (HDD) | Big data, sequential I/O | Good throughput |
| sc1 (HDD) | Infrequent access, archival | Low cost |
Critical for the exam: EBS volumes are AZ-specific. You cannot attach a volume from us-east-1a to an instance in us-east-1b. This is a common gotcha.
Networking & Security
Section titled “Networking & Security”Security Groups act as virtual firewalls, controlling inbound and outbound traffic at the instance level. Elastic IPs are static, publicly routable addresses that can be remapped between instances. Elastic Load Balancers (ALB, NLB, CLB) distribute traffic across multiple EC2 instances.
AWS Lambda
Section titled “AWS Lambda”Lambda is fully serverless—AWS manages servers, scaling, and patching. You pay only for compute time consumed.
Core Concepts
Section titled “Core Concepts”Lambda functions are event-driven and scale automatically. Triggers include S3, DynamoDB Streams, Kinesis, SNS, API Gateway, CloudWatch Events, and more. Execution happens in isolated execution environments.
Concurrency & Scaling
Section titled “Concurrency & Scaling”Lambda concurrency is the number of functions executing simultaneously. AWS allocates one execution environment per concurrent request.
Default concurrency limits depend on account and region, but reserved/provisioned concurrency gives you explicit control.
Cold Starts & Optimization
Section titled “Cold Starts & Optimization”A cold start occurs when AWS must create a new execution environment to run your function. Initialization overhead (Java can take 1-2 seconds; Python faster) impacts latency.
Cold start factors: Function size, language runtime, VPC attachment (worst), and code complexity. VPC-attached Lambda is particularly slow because it must attach an ENI to the function.
Timeout & Limitations
Section titled “Timeout & Limitations”Max execution time is 15 minutes (900 seconds). Lambda is not suited for long-running processes—use Fargate or EC2 for batch jobs that exceed 15 minutes.
AWS Elastic Beanstalk
Section titled “AWS Elastic Beanstalk”Elastic Beanstalk is a Platform as a Service (PaaS)—you upload code, AWS manages infrastructure (EC2, load balancing, auto-scaling, monitoring).
How It Works
Section titled “How It Works”Upload your application code, choose a platform (Java, Python, Node.js, Go, Docker, etc.), and Beanstalk handles the rest. It provisions EC2 instances, applies auto-scaling policies, configures ELBs, and manages monitoring.
Environments are all resources Beanstalk creates: EC2 instances, Auto Scaling Group, Elastic Load Balancer, and RDS (optional).
Configuration & Customization
Section titled “Configuration & Customization”.ebextensions YAML files (placed in .ebextensions/ at app root) customize Beanstalk environments. Common configs: install packages, set environment variables, tune OS parameters, or deploy custom code.
Beanstalk handles deployment orchestration, health monitoring, and rollback if deployment fails. It integrates with CodePipeline for CI/CD automation.
AWS Serverless Application Model (SAM)
Section titled “AWS Serverless Application Model (SAM)”SAM is a framework and shorthand syntax for defining serverless applications. It’s built on CloudFormation.
SAM Templates & Transform
Section titled “SAM Templates & Transform”A SAM template is a YAML file using simplified syntax for Lambda functions, API Gateway APIs, DynamoDB tables, and more. At deploy time, SAM transforms the template into standard CloudFormation.
| Step | Command | What Happens |
|---|---|---|
| Build | sam build | Compiles, installs deps, creates artifact in .aws-sam/ |
| Package | sam package | Creates S3 bucket for artifacts (optional, implicit in deploy) |
| Deploy | sam deploy | Transforms to CloudFormation, deploys stack, creates resources |
Local Testing
Section titled “Local Testing”SAM CLI allows local testing and debugging without deploying to AWS. sam local start-api runs a local API Gateway mock. Requires Docker to run Lambda containers locally.
Best Practices
Section titled “Best Practices”SAM enforces least privilege IAM policies, secure environment variable handling, and Infrastructure as Code principles. Every resource gets a logical ID, making it easy to reference and update.
Key Concepts & Best Practices
Section titled “Key Concepts & Best Practices”Elasticity & Scalability: Design to leverage AWS’s elastic capacity. Use Auto Scaling, Lambda concurrency controls, and load balancers to handle variable traffic.
Security: Always use IAM roles (never raw access keys on EC2), enable Security Groups, encrypt EBS volumes, and implement least-privilege policies.
Cost Optimization: Use Spot Instances for fault-tolerant workloads, Reserved Instances for predictable baseline load, and Savings Plans for compute flexibility.
Monitoring & Logging: CloudWatch provides metrics, alarms, and logs. Set up dashboards and alarms for critical thresholds to catch issues early.
Infrastructure as Code: Use CloudFormation, SAM, or Terraform to codify and version your infrastructure. This enables reproducibility and disaster recovery.