A CDK construct that periodically invokes your Lambda functions to prevent them from transitioning to the inactive state.
Lambda functions become inactive after approximately 14 days of idleness. Waking an inactive function can take up to 90 seconds. This construct invokes your functions every 3 days to keep them active.
npm i @beesolve/lambda-keep-activeimport{LambdaKeepActive}from"@beesolve/lambda-keep-active";constwarmer=newLambdaKeepActive(this,"KeepAliveLambda");consthandler=newNodejsFunction(this,"Handler",{/** your props */});warmer.keepActive(handler);Use the keptActive wrapper in your Node.js Lambda handlers to short-circuit keep-alive invocations:
import{keptActive}from"@beesolve/lambda-keep-active/runtime";exportconsthandler=keptActive(async()=>{// your handler code});For Bun Lambda handlers, use keptActiveFetch:
import{keptActiveFetch}from"@beesolve/lambda-keep-active/runtime";exportdefault{fetch: keptActiveFetch(async(request: Request): Promise<Response>=>{// your handler codereturnnewResponse();}),};