Build optimized serverless functions with Lambda
Build optimized serverless functions with Lambda Creates Lambda functions with proper handler templates, memory optimization, and cold start mitigation for Python and Node.js runtimes.
/plugin marketplace add pluginagentmarketplace/custom-plugin-aws/plugin install pluginagentmarketplace-aws-cloud-assistant@pluginagentmarketplace/custom-plugin-awsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/lambda-template.pyassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyDevelop high-performance serverless functions with best practices.
| Attribute | Value |
|---|---|
| AWS Service | Lambda |
| Complexity | Medium |
| Est. Time | 5-15 min |
| Prerequisites | IAM Role, (Optional) VPC |
| Parameter | Type | Description | Validation |
|---|---|---|---|
| function_name | string | Function name | ^[a-zA-Z0-9-_]{1,64}$ |
| runtime | string | Runtime environment | python3.12, nodejs20.x, etc. |
| handler | string | Handler function | module.function |
| role_arn | string | Execution role ARN | Valid IAM role ARN |
| Parameter | Type | Default | Description |
|---|---|---|---|
| memory_mb | int | 128 | Memory allocation (128-10240) |
| timeout | int | 3 | Timeout seconds (1-900) |
| architecture | string | x86_64 | x86_64 or arm64 |
| environment | object | {} | Environment variables |
| vpc_config | object | null | VPC configuration |
1. Package code and dependencies
2. Create/update function
3. Configure triggers
4. Set concurrency limits
5. Test invocation
6. Monitor cold starts
# Create deployment package
zip -r function.zip . -x "*.git*"
# Create function
aws lambda create-function \
--function-name my-function \
--runtime python3.12 \
--architectures arm64 \
--handler main.handler \
--role arn:aws:iam::123456789012:role/lambda-role \
--zip-file fileb://function.zip \
--memory-size 1024 \
--timeout 30 \
--environment "Variables={LOG_LEVEL=INFO}" \
--tracing-config Mode=Active
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def handler(event, context):
"""
Lambda handler function.
Args:
event: Trigger event data
context: Runtime context (request_id, memory_limit, etc.)
Returns:
Response object or value
"""
try:
logger.info(f"Event: {json.dumps(event)}")
# Business logic here
result = process_event(event)
return {
"statusCode": 200,
"body": json.dumps(result)
}
except Exception as e:
logger.error(f"Error: {str(e)}")
return {
"statusCode": 500,
"body": json.dumps({"error": str(e)})
}
export const handler = async (event, context) => {
console.log('Event:', JSON.stringify(event));
try {
const result = await processEvent(event);
return {
statusCode: 200,
body: JSON.stringify(result)
};
} catch (error) {
console.error('Error:', error);
return {
statusCode: 500,
body: JSON.stringify({ error: error.message })
};
}
};
| Memory | vCPU | Network | Use Case |
|---|---|---|---|
| 128 MB | 0.08 | Low | Simple transforms |
| 512 MB | 0.33 | Low | Basic API handlers |
| 1024 MB | 0.58 | Medium | Standard workloads |
| 1769 MB | 1.0 | Medium | CPU-bound tasks |
| 3008 MB | 2.0 | High | Parallel processing |
| 10240 MB | 6.0 | Very High | Data processing |
| Symptom | Cause | Solution |
|---|---|---|
| Timeout | Long execution | Increase timeout, optimize code |
| OOM (signal: killed) | Memory exceeded | Increase memory |
| Import error | Missing dependency | Check package includes deps |
| Permission denied | IAM role | Update execution role |
Task timed out after X.XX seconds → Increase timeout
Runtime exited with error: signal: killed → Increase memory
Unable to import module → Check handler path/dependencies
ECONNREFUSED → Check VPC/security group
def test_lambda_handler():
# Arrange
event = {"key": "value"}
context = MockContext()
# Act
response = handler(event, context)
# Assert
assert response["statusCode"] == 200
body = json.loads(response["body"])
assert "result" in body
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture('process_data')
def process_data(data):
# Traced function
pass
{
"level": "INFO",
"message": "Processing request",
"request_id": "abc-123",
"function_name": "my-function",
"cold_start": true
}
assets/lambda-template.py - Python handler templateThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.