Serverless Mastery
Purpose
Comprehensive serverless architecture management, focusing on AWS Lambda cold-start mitigation, Terraform IaC provisioning, and highly scalable event-driven patterns.
Core Principles
- Minimize deployment package size to reduce cold start latency.
- Leverage provisioned concurrency for latency-sensitive endpoints.
- Optimize execution environments using Graviton and minimal runtimes.
- Apply principle of least privilege in IAM roles.
- Use Infrastructure as Code (Terraform) for reproducible environments.
Agent Protocol
- Triggers: "deploy lambda", "optimize cold start"
- Input Context Required: AWS credentials, source code, traffic patterns
- Output Artifact: Terraform plan, optimized deployment zip
- Response Formats:
{ "status": "deployed", "lambda_arn": "arn:aws:lambda:us-east-1:123456789012:function:my-func", "cold_start_est_ms": 120 }
Decision Matrix
Is workload latency-sensitive?
+-- Yes --> Use Provisioned Concurrency
+-- No --> Standard on-demand Lambda
Detailed Architectural Overview
[API Gateway] ---> [Lambda Function] ---> [DynamoDB]
(Graviton2/Python)
Workflow Steps
Phase 1: Analysis
- Inspect source
- Identify deps
- Measure size
- Check limits
Phase 2: Optimization
- Strip binaries
- Bundle code
- Set architecture
- Tune memory
Phase 3: IaC Generation
- Write main.tf
- Define variables.tf
- Setup outputs.tf
- Provider config
Phase 4: Deployment
- terraform init
- terraform plan
- terraform apply
- verify state
Phase 5: Validation
- Invoke lambda
- Measure latency
- Verify logs
- End-to-end test
Phase 6: Monitoring
- Setup CloudWatch
- Create alarms
- Dashboard config
- Set alerts
Extended Troubleshooting Guide
| Symptom | Primary Cause | Mitigation Action |
|---|---|---|
| Timeout | Cold start | Increase timeout or use provisioned concurrency |
| Missing Module | Bad bundling | Check deployment package contents |
| Access Denied | IAM role | Attach correct policies |
| Throttling | Concurrency limit | Request quota increase |
| High cost | Over-provisioned | Tune memory/concurrency |
| Missing logs | CW permissions | Add AWSLambdaBasicExecutionRole |
Complete Execution Scenario
Start -> Build -> Optimize -> Plan -> Apply -> Done
Rules and Guidelines
- Always bundle dependencies.
- Never hardcode credentials.
- Use Terraform state locking.
- Tag all resources.
- Implement dead-letter queues for async lambdas.
Reference Guides
- Architecture Guide
- Cold Start Opt
- Terraform Core
- Security Model
- Monitoring Setup
- Cost Tuning
- Advanced Networking
- CI/CD Pipelines
Handoff
Refer to aws-core skill for baseline AWS authentication.