Lambda
💡 Definition
AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers. You pay only for the compute time you consume.
🔑 Key Concepts
- Function: The code you upload to Lambda.
- Trigger: The event that causes the function to run (e.g., file upload to S3, HTTP request via API Gateway, record update in DynamoDB).
- Runtime: The language environment (Python, Node.js, Java, Go, etc.).
- Serverless: No OS access, no patching, automatic scaling.
⚙️ How it Works
- Upload Code: Write your function logic.
- Configure Trigger: Set up an event source (e.g., "When a file lands in S3 bucket X...").
- Execution: When the event occurs, Lambda spins up, runs the code, and shuts down.
- Scale: If 1,000 events happen at once, Lambda runs 1,000 copies of the function instantly.
🎯 Use Cases
- Real-time File Processing: Resize images immediately after upload to S3.
- Data Transformation: ETL jobs, filtering data streams.
- Backend Logic: Powering web/mobile apps via API Gateway.
- Automated Cron Jobs: Scheduled tasks using EventBridge.
💰 Pricing Model
- Requests: Charge per 1 million requests ($0.20).
- Duration: Charge for GB-seconds (how long the code runs * how much memory configured).
- Free Tier: 1 million free requests and 400,000 GB-seconds per month forever.
📝 Exam Tips (CLF-C02)
- Time Limit: Lambda functions have a maximum execution time (currently 15 minutes). Not for long-running processes (use EC2 or Fargate for that).
- Event-Driven: It runs in response to events.
- Cost-Effective: Zero cost when code is not running (unlike EC2 which charges when idle).
See Also: * Fargate * API Gateway