Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计通过

aws-lambda-python-integrationAWS lambda Python 集成

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

475

周安装

20

GitHub Stars

217

下载量

166
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:aws-lambda-python-integration(AWS lambda Python 集成)
来源仓库:https://github.com/giuseppe-trisciuoglio/developer-kit-claude-code
仓库路径:skills/aws-lambda-python-integration
安装命令:
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit-claude-code --skill aws-lambda-python-integration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

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

简介

aws-lambda-python-integration 用于辅助 Python 项目开发、测试和依赖管理。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 等宿主环境中的开发任务。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 需确认虚拟环境和依赖版本,涉及执行脚本或读写文件时应明确目录和范围。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

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

ApproachCold StartBest ForComplexity
AWS Chalice< 200msREST APIs, rapid development, built-in routingLow
Raw Python< 100msSimple handlers, maximum control, minimal dependenciesLow

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 CloudWatch logs for initialization errors and run sam logs to diagnose issues.

Security Considerations

  • Never hardcode credentials; use IAM roles and environment variables
  • Validate all input data
  • Use least privilege IAM policies
  • Enable CloudTrail for audit logging

References

For detailed guidance on specific topics:

Examples

Example 1: Create an AWS Chalice REST API

Input:

Create a Python Lambda REST API using AWS Chalice for a todo application

Process:

  1. Initialize Chalice project with chalice new-project
  2. Configure routes for CRUD operations
  3. Set up DynamoDB integration
  4. Configure deployment stages
  5. Deploy with chalice deploy

Output:

  • Complete Chalice project structure
  • REST API with CRUD endpoints
  • DynamoDB table configuration
  • Deployment configuration

Example 2: Optimize Cold Start for Raw Python

Input:

My Python Lambda has slow cold start, how do I optimize it?

Process:

  1. Analyze imports and initialization code
  2. Move heavy imports inside functions (lazy loading)
  3. Cache boto3 clients at module level
  4. Remove unnecessary dependencies
  5. Use provisioned concurrency if needed

Output:

  • Refactored code with lazy loading
  • Optimized cold start < 100ms
  • Dependency analysis

Example 3: Deploy with GitHub Actions

Input:

Configure CI/CD for Python Lambda with SAM

Process:

  1. Create GitHub Actions workflow
  2. Set up Python environment and dependencies
  3. Run pytest with coverage
  4. Package with SAM
  5. Deploy to dev/prod stages

Output:

  • Complete .github/workflows/deploy.yml
  • Multi-stage pipeline
  • Integrated test automation

Version

Version: 1.0.0

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.12%
按下载量换算58

Claude

28.57%
按下载量换算47

Cursor

20.94%
按下载量换算35

Gemini CLI

8.86%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills