It's possible to configure a Lambda warmer function using AWS SAM.
Resources:
# ...
Web:
Type: AWS::Serverless::Function # https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: web/
Handler: lambda.handler
Runtime: nodejs10.x
FunctionName: !Sub myproject-${Stage}-web
Events:
Root:
Type: Api # https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /
Method: ANY
RestApiId: !Ref WebRestApi
RootProxy:
Type: Api # https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /{proxy+}
Method: ANY
RestApiId: !Ref WebRestApi
WarmingSchedule:
Type: Schedule
Properties:
Schedule: rate(5 minutes)
Input: '{ "warmer":true,"concurrency":3 }'
MemorySize: 512
Policies:
- AWSLambdaRole
How would one create a warmer using the AWS CDK? Is there an "out of the box" solution or would a custom lambda function using Schedule.cron
be necessary?
You would need a cron job in Cloudwatch which triggers your lambda to keep it warm or you use the serverless plugin:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.