AWS Lambda Deep Dive Cheat Sheet
Practical reference for writing, deploying, and configuring AWS Lambda functions including triggers, layers, and CLI usage.
2 PagesIntermediateFeb 12, 2026
Python Handler
Basic Lambda function handler signature.
python
import jsondef lambda_handler(event, context): # event: dict with the trigger payload # context: runtime info (request_id, remaining time, etc.) body = json.loads(event.get('body', '{}')) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json'}, 'body': json.dumps({'message': f"Hello {body.get('name', 'World')}"}) }
CLI: Create & Update Function
Deploy and update a function via the AWS CLI.
bash
# Zip and createzip function.zip lambda_function.pyaws lambda create-function \ --function-name my-func \ --runtime python3.12 \ --role arn:aws:iam::123456789012:role/lambda-exec-role \ --handler lambda_function.lambda_handler \ --zip-file fileb://function.zip# Update code after changesaws lambda update-function-code \ --function-name my-func --zip-file fileb://function.zip# Invokeaws lambda invoke --function-name my-func out.json
Environment & Config Update
Set memory, timeout, and environment variables.
bash
aws lambda update-function-configuration \ --function-name my-func \ --timeout 30 \ --memory-size 256 \ --environment "Variables={STAGE=prod,LOG_LEVEL=info}"
Common Event Sources
Key common event sources to know.
- API Gateway- HTTP requests invoke the function synchronously (REST or HTTP API)
- S3- Object created/removed events trigger the function asynchronously
- EventBridge- Scheduled (cron) or event-pattern based invocations
- SQS- Lambda polls the queue and processes messages in batches
- DynamoDB Streams- Invoked on table item changes (insert/update/delete)
Key Concepts
Key key concepts to know.
- Cold Start- Latency from initializing a new execution environment before first invoke
- Layer- Shared zip archive of libraries/dependencies attached to multiple functions
- Concurrency- Number of simultaneous executions; can set reserved or provisioned concurrency
- Execution Role- IAM role granting the function permissions to call other AWS services
- Timeout- Max runtime per invocation, configurable up to 900 seconds (15 min)
Pro Tip
Initialize SDK clients and heavy imports outside the handler function body — code outside the handler runs once per execution environment and is reused across warm invocations, cutting latency significantly.
Was this cheat sheet helpful?
Explore Topics
#AWSLambdaDeepDive#AWSLambdaDeepDiveCheatSheet#CloudComputing#Intermediate#PythonHandler#CLI#Create#Update#Functions#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance