aws-lambda-python

A guide to developing Python functions for AWS Lambda, Amazon’s service for running code without managing servers. It covers handlers, packaging layers, AWS SDK access, logging, error handling, testing, validation, and performance practices.

In plain words
What is it for?
Use it to structure Python Lambda projects, package dependencies, connect to AWS services such as S3 or DynamoDB, add logging and validation, and write tests.
Why use it?
It helps keep Lambda functions small and organized by separating event handling from business logic, data access, and models.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/eliecer2000/kiro-bootstrap/aws-lambda-python
Any agent
npx skills add eliecer2000/kiro-bootstrap --skill aws-lambda-python
Clone the repo
git clone --depth 1 https://github.com/eliecer2000/kiro-bootstrap

Made for: Claude Code, Codex.

Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,241 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00036 $0.02241
Opus 5 $0.00018 $0.01120
Sonnet 5 $0.00007 $0.00448
Haiku 4.5 $0.00004 $0.00224

Measured yesterday against content hash 65dcb4c22901, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

aws-lambda-python scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/aws-lambda-python/SKILL.md · 286 lines

How it starts

The opening of the file, as written. The whole thing — 286 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AWS Lambda Python

Skill para desarrollo de funciones Lambda en Python: handlers, empaquetado, layers, AWS SDK (boto3), Powertools, logging estructurado, manejo de errores, testing y mejores prácticas de rendimiento.

Principios fundamentales

  • Un handler, una responsabilidad. Evitar Lambdas monolíticos.
  • Separar lógica de negocio del handler. El handler solo parsea el evento, invoca la lógica y formatea la respuesta.
  • Usar AWS Lambda Powertools para Python en todo proyecto: logging, tracing, metrics, validation, idempotency.
  • Tipado estricto con type hints y validación con Pydantic o Powertools Parser.
  • Inicializar clientes AWS fuera del handler (reutilización en warm starts).

Estructura de proyecto recomendada

functions/
├── mi_funcion/
│   ├── __init__.py
│   ├── handler.py          # Entry point del Lambda
│   ├── service.py          # Lógica de negocio
│   ├── repository.py       # Acceso a datos (DynamoDB, S3, etc.)
│   ├── models.py           # Pydantic models / dataclasses
│   └── exceptions.py       # Excepciones custom
├── shared/
│   ├── __init__.py
│   ├── middleware.py        # Middleware compartido
│   └── constants.py
├── tests/
│   ├── unit/
│   │   ├── test_service.py
│   │   └── test_handler.py
│   └── integration/
│       └── test_api.py
├── requirements.txt
└── pyproject.toml

Handler con Powertools (patrón recomendado)

from aws_lambda_powertools import Logger, Tracer, Metrics
from aws_lambda_powertools.event_handler import APIGatewayHttpResolver
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.metrics import MetricUnit
from aws_lambda_powertools.utilities.typing import LambdaContext
from aws_lambda_powertools.utilities.validation import validate

logger = Logger()
tracer = Tracer()
metrics = Metrics()
app = APIGatewayHttpResolver()

# Clientes AWS inicializados fuera del handler (warm start reuse)
import boto3
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(os.environ["TABLE_NAME"])

@app.get("/items")
@tracer.capture_method
def list_items():
    items = table.query(
        KeyConditionExpression="PK = :pk",
        ExpressionAttributeValues={":pk": "ITEMS"},
    )
    return {"items": items.get("Items", [])}

@app.post("/items")
@tracer.capture_method
def create_item():
    body = app.current_event.json_body
    # Validar con Pydantic
    item = ItemCreate(**body)
    table.put_item(Item=item.to_dynamo())
    metrics.add_metric(name="ItemCreated", unit=MetricUnit.Count, value=1)
    return {"id": item.id}, 201

@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_HTTP)
@tracer.capture_lambda_handler
@metrics.log_metrics(capture_cold_start_metric=True)
def handler(event: dict, context: LambdaContext) -> dict:
    return app.resolve(event, context)

Read the full file on GitHub · 286 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 286 lines · 36 tokens per session scan A 65dcb4c22901

Subscribe to this mod's changes

aws-lambda-python is a skill published in the GitHub repository eliecer2000/kiro-bootstrap (9 stars, last pushed 5mo ago), licensed MIT. It adds 36 tokens to every session and 2,241 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.