aws-serverless-patterns
Apply AWS serverless patterns with Lambda, API Gateway, DynamoDB, and Step Functions. Use for event-driven architectures, APIs, and scalable applications.
Works with
---
name: aws-serverless-patterns
description: Apply AWS serverless patterns with Lambda, API Gateway, DynamoDB, and Step Functions. Use for event-driven architectures, APIs, and scalable applications.
license: MIT
---
# AWS Serverless Patterns
Build scalable serverless applications on AWS.
## Core Services
- **Lambda**: Serverless compute
- **API Gateway**: REST and WebSocket APIs
- **DynamoDB**: NoSQL database
- **S3**: Object storage
- **SQS/SNS**: Messaging
- **Step Functions**: Orchestration
## Patterns
### Lambda Function Handler
```python
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Users')
def lambda_handler(event, context):
try:
user_id = event['pathParameters']['id']
response = table.get_item(Key={'userId': user_id})
if 'Item' not in response:
return {
'statusCode': 404,
'body': json.dumps({'error': 'User not found'})
}
return {
'statusCode': 200,
'body': json.dumps(response['Item'])
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps({'error': str(e)})
}
```
### API Gateway Integration
```yaml
# serverless.yml
service: user-api
provider:
name: aws
runtime: python3.9
environment:
USERS_TABLE: ${self:service}-users-${self:provider.stage}
functions:
getUser:
handler: handler.get_user
events:
- http:
path: users/{id}
method: get
cors: true
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.USERS_TABLE}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
```
### Event-Driven Pattern
```python
# SQS + Lambda pattern
def process_order(event, context):
for record in event['Records']:
message = json.loads(record['body'])
order_id = message['orderId']
# Process order
process_payment(order_id)
update_inventory(order_id)
send_confirmation(order_id)
```
## Best Practices
- Use environment variables for configuration
- Implement proper error handling and retries
- Set appropriate memory and timeout settings
- Use Lambda layers for shared dependencies
- Implement CloudWatch logging and monitoring
- Use X-Ray for distributed tracing
- Follow least privilege IAM policies
## Resources
- AWS Serverless Application Repository
- Serverless Framework Documentation
- AWS Well-Architected FrameworkMore DevOps & Infrastructure skills
azure-ai
microsoft/azure-skills
Use for Azure AI: Search, Speech, OpenAI, Document Intelligence. Helps with search, vector/hybrid search, speech-to-text, text-to-speech, transcription, OCR. WHEN: AI Search, query search, vector search, hybrid search, semantic search, speech-to-text, text-to-speech, transcribe, OCR, convert text to speech.
appinsights-instrumentation
microsoft/azure-skills
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. WHEN: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices.
azure-storage
microsoft/azure-skills
Azure Storage Services including Blob Storage, File Shares, Queue Storage, Table Storage, and Data Lake. Answers questions about storage access tiers (hot, cool, cold, archive), when to use each tier, and tier comparison. Provides object storage, SMB file shares, async messaging, NoSQL key-value, and big data analytics. Includes lifecycle management. USE FOR: blob storage, file shares, queue storage, table storage, data lake, upload files, download blobs, storage accounts, access tiers, storage tiers, hot cool cold archive, storage tier comparison, when to use storage tiers, lifecycle management, Azure Storage concepts. DO NOT USE FOR: SQL databases, Cosmos DB (use azure-prepare), messaging with Event Hubs or Service Bus (use azure-messaging).

