aws-lambda-python-integration

giuseppe-trisciuoglio/developer-kit · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-lambda-python-integration
0 commentsdiscussion
summary

Patterns for creating high-performance AWS Lambda functions in Python with optimized cold starts and clean architecture.

skill.md

AWS Lambda Python Integration

Patterns for creating high-performance AWS Lambda functions in Python with optimized cold starts and clean architecture.

Overview

AWS Lambda Python integration with two approaches: AWS Chalice (full-featured framework) and Raw Python (minimal overhead). Both support API Gateway/ALB integration with production-ready configurations.

When to Use

Use this skill when:

  • Creating new Lambda functions in Python
  • Migrating existing Python applications to Lambda
  • Optimizing cold start performance for Python Lambda
  • Choosing between framework-based and minimal Python approaches
  • Configuring API Gateway or ALB integration
  • Setting up deployment pipelines for Python Lambda

Instructions

1. Choose Your Approach

Approach Cold Start Best For Complexity
AWS Chalice < 200ms REST APIs, rapid development, built-in routing Low
Raw Python < 100ms Simple handlers, maximum control, minimal dependencies Low

2. Project Structure

AWS Chalice Structure

my-chalice-app/
├── app.py                    # Main application with routes
├── requirements.txt          # Dependencies
├── .chalice/
│   ├── config.json          # Chalice configuration
│   └── deploy/              # Deployment artifacts
├── chalicelib/              # Additional modules
│   ├── __init__.py
│   └── services.py
└── tests/
    └── test_app.py

Raw Python Structure

my-lambda-function/
├── lambda_function.py       # Handler entry point
├── requirements.txt         # Dependencies
├── template.yaml            # SAM/CloudFormation template
└── src/                     # Additional modules
    ├── __init__.py
    ├── handlers.py
    └── utils.py

3. Implementation Examples

See the References section for detailed implementation guides. Quick examples:

AWS Chalice:

from chalice import Chalice
app = Chalice(app_name='my-api')

@app.route('/')
def index():
    return {'message': 'Hello from Chalice!'}

Raw Python:

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps({'message': 'Hello from Lambda!'})
    }

Core Concepts

Cold Start Optimization

Key strategies:

  1. Initialize at module level - Persists across warm invocations
  2. Use lazy loading - Defer heavy imports until needed
  3. Cache boto3 clients - Reuse connections between invocations

See Raw Python Lambda for detailed patterns.

Connection Management

Create clients at module level and reuse:

_dynamodb = None

def get_table():
    global _dynamodb
    if _dynamodb is None:
        _dynamodb = boto3.resource('dynamodb').Table('my-table')
    return _dynamodb

Environment Configuration

class Config:
    TABLE_NAME = os.environ.get('TABLE_NAME')
    DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'

    @classmethod
    def validate(cls):
        if not cls.TABLE_NAME:
            raise ValueError("TABLE_NAME required")

Best Practices

Memory and Timeout Configuration

  • Memory: Start with 256MB for simple handlers, 512MB for complex operations
  • Timeout: Set based on expected processing time
    • Simple handlers: 3-5 seconds
    • API with DB calls: 10-15 seconds
    • Data processing: 30-60 seconds

Dependencies

Keep requirements.txt minimal:

# Core AWS SDK - always needed
boto3>=1.35.0

# Only add what you need
requests>=2.32.0  # If calling external APIs
pydantic>=2.5.0   # If using data validation

Error Handling

Return proper HTTP codes with request ID:

def lambda_handler(event, context):
    try:
        result = process_event(event)
        return {'statusCode': 200, 'body': json.dumps(result)}
    except ValueError as e:
        return {'statusCode': 400, 'body': json.dumps({'error': str(e)})}
    except Exception as e:
        print(f"Error: {str(e)}")  # Log to CloudWatch
        return {'statusCode': 500, 'body': json.dumps({'error': 'Internal error'})}

See Raw Python Lambda for structured error patterns.

Logging

Use structured logging for CloudWatch Insights:

import logging, json
logger = logging.getLogger()
logger.setLevel(logging.INFO)

# Structured log
logger.info(json.dumps({
    'eventType': 'REQUEST',
    'requestId': context.aws_request_id,
    'path': event.get('path')
}))

See Raw Python Lambda for advanced patterns.

Deployment Options

Quick Start

Validation Checkpoint: Always run serverless print or sam validate before deploying to catch configuration errors early.

Serverless Framework:

# serverless.yml
service: my-python-api
provider:
  name: aws
  runtime: python3.12  # or python3.11
functions:
  api:
    handler: lambda_function.lambda_handler
    events:
      - http:
          path: /{proxy+}
          method: ANY

AWS SAM:

# template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
  ApiFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: ./
      Handler: lambda_function.lambda_handler
      Runtime: python3.12  # or python3.11
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /{proxy+}
            Method: ANY

AWS Chalice:

chalice new-project my-api
cd my-api
chalice local 8080  # Test locally before deploying
chalice deploy --stage dev

Validation Checkpoint: Test locally with chalice local or sam local invoke before deploying to production.

For complete deployment configurations including CI/CD, environment-specific settings, and advanced SAM/Serverless patterns, see Serverless Deployment.

Constraints and Warnings

Lambda Limits

  • Deployment package: 250MB unzipped maximum (50MB zipped)
  • Memory: 128MB to 10GB
  • Timeout: 15 minutes maximum
  • Concurrent executions: 1000 default (adjustable)
  • Environment variables: 4KB total size

Python-Specific Considerations

  • Cold start: Python has excellent cold start performance; avoid heavy imports at module level
  • Dependencies: Keep requirements.txt minimal; use Lambda Layers for shared dependencies
  • Native dependencies: Must be compiled for Amazon Linux 2 (x86_64 or arm64)

Common Pitfalls

  1. Importing heavy libraries at module level - Defer to function level if not always needed
  2. Not handling Lambda context - Use context.get_remaining_time_in_millis() for timeout awareness
  3. Not validating input - Always validate and sanitize event data
  4. Printing sensitive data - Be careful with logs and CloudWatch

Error Recovery: If deployment fails, check

how to use aws-lambda-python-integration

How to use aws-lambda-python-integration on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add aws-lambda-python-integration
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-lambda-python-integration

The skills CLI fetches aws-lambda-python-integration from GitHub repository giuseppe-trisciuoglio/developer-kit and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/aws-lambda-python-integration

Reload or restart Cursor to activate aws-lambda-python-integration. Access the skill through slash commands (e.g., /aws-lambda-python-integration) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.567 reviews
  • Isabella Mehta· Dec 16, 2024

    aws-lambda-python-integration is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Isabella Rao· Dec 16, 2024

    Keeps context tight: aws-lambda-python-integration is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Zara Torres· Dec 12, 2024

    aws-lambda-python-integration fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Arjun Torres· Dec 4, 2024

    I recommend aws-lambda-python-integration for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Piyush G· Nov 27, 2024

    Solid pick for teams standardizing on skills: aws-lambda-python-integration is focused, and the summary matches what you get after install.

  • Anika Torres· Nov 23, 2024

    Useful defaults in aws-lambda-python-integration — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Rahul Santra· Nov 19, 2024

    aws-lambda-python-integration reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Zara Flores· Nov 7, 2024

    aws-lambda-python-integration has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Omar Abbas· Nov 3, 2024

    We added aws-lambda-python-integration from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Omar Rahman· Oct 26, 2024

    aws-lambda-python-integration fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

showing 1-10 of 67

1 / 7