Lambda Warmer

raw JSON →
0.6.0 verified Fri May 01 auth: no python

A Python decorator to keep AWS Lambda functions warm and monitor cold starts. The decorator intercepts warmer invocations (typically from a CloudWatch Event) and returns a no-op response, while measuring cold start duration. Current version 0.6.0. Release cadence is low, last updated in 2020.

pip install lambda-warmer-py
error ModuleNotFoundError: No module named 'lambda_warmer'
cause Package is not installed or import path is wrong.
fix
Install with 'pip install lambda-warmer-py' and import as 'from lambda_warmer import warmer'.
error Unable to locate credentials
cause Lambda environment lacks AWS credentials (e.g., when running locally).
fix
Set AWS credentials via environment variables or use an IAM role when deploying to Lambda.
gotcha The warmer decorator must be applied to the handler function that Lambda calls directly. If you wrap the handler inside another decorator, the warmer may not intercept invocations correctly.
fix Ensure @warmer is the outermost decorator (closest to the function definition) or applied directly to the raw handler.
deprecated The library uses boto3 to publish custom metrics to CloudWatch, but this requires IAM permissions (cloudwatch:PutMetricData). Without proper permissions, the decorator silently fails.
fix Attach an IAM policy granting cloudwatch:PutMetricData to your Lambda execution role, or override the metric publishing logic.

Decorate your Lambda handler with @warmer to handle warm-up pings and log cold start metrics.

from lambda_warmer import warmer

@warmer

def handler(event, context):
    return {'statusCode': 200, 'body': 'Hello World'}