Skip to main content

Warmer Utility for Lambda Function

Project description

This is a utility project designed to cater neccessities for warming up Lambda functions to prevent cold starts.

Table Of Contents

upload-artifacts-and-release-new-version PyPI version

Installing Warmer

To install module, run the below command:

python3 -m pip install py_lambda_warmer

# or

python3 -m pip install py_lambda_warmer==<release-version>

Using Warmer

This is very easy to incorporate in your existing Python Lambda Handlers. Follow the below code.

from warmer import warmer
@warmer(flag="custom_event_key")
def handler(event, context):
    pass

If you handler is a Flask/FastApi application, you may follow below steps:

from warmer import warmer
from flask import Flask
app = Flask()
@warmer(flag="custom_event_key")
def application(event, context):
    app(event, context)

# or

application = warmer(flag="custom_event_key")(app)

# you may now use application as your handler

warmer will help you cater the custom events that are coming for warming Lambda function.

Setting up Event Bridge Notifications

You can also setup you custom event bridge schedule for Lambda function using the Terraform Resource code mentioned in the repository.

Simply download the Terraform code attached in the release and unzip it.

wget https://github.com/satyamsoni2211/LambdaWarmerPy/releases/download/${release}/terraform_code.zip
unzip terraform_code.zip -d terraform_code/
cd terraform_code/
# creating variable file required by terraform
cat << EOF > .auto.tfvars
arn = <arn of your lambda function>
profile = <profile alias for aws>
region = <region for aws lambda>
EOF
# initiating and applying
terraform init
terraform plan -out tfplan
terraform apply tfplan

You may also modify resource names as per your requirements in the code.

Happy Warming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_lambda_warmer-0.0.4.macosx-12-arm64.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

py_lambda_warmer-0.0.4-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page