@ixor/aws-cdk-lambda-warmer
v0.1.0
Published
## Description
Readme
Lambda Warmer Lambda: Keep your Lambda's warm
Description
This repo contains a AWS CDK stack that can be deployed to any AWS account. The stack contains a single Lambda and IAM permissions to allow CloudWatch Events to invoke the function, and the function to invoke all Lambda's in the account/region where the stack is deployed.
You should, preferably in an automated way, create a AWS CloudWatch
event for every function you want to be warm. The event to sent to the
KeepWarm lambda looks like this:
{
"lambdaArn": "arn:aws:lambda:eu-central-1:123456789012:function:functionToKeepWarm",
"count": 5
}When the KeepWarm function is invoked by the CloudWatch Rule, this wil happen:
- the event is read and interpreted
- the
KeepWarmfunction asynchronously invokes the Lambda to be kept warmcounttimes with a dummy event containing 2 propertiesdummyanddummySleepSeconds - the target Lambda will interpret the dummy event, and will
sleepfor the requested amount of seconds - without the sleep, the target Lambda might have already finished before the next
invoke by the
KeepWarmlambda, resulting in less than desired warm lambda's
Deploying this AWS CDK stack
To deploy the KeepWarm Lambda on a AWS account:
- set credentials with sufficient permissions
- make sure all requirements are met
aws-cdkis installedaws-cliis installed
- run this command:
cdk deployHow to change your Lambda to correctly process the dummy event
- Check for the
dummyproperty in the incoming event - Sleep for
dummySleepSecondsseconds (default to 1) - Return immediately after the sleep
Links and Resources
- https://www.npmjs.com/package/@ixor/aws-cdk-ixor-lambda
