Skip to content

A lambda function to warm another lambda function

Notifications You must be signed in to change notification settings

mununki/lambda-warmer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda Warmer

The related post: https://moondaddi.dev/post/2019-03-23-how-to-warm-lambda-function/

This is a lambda function to warm another lambda function in AWS. Especially, this is to solve a cold start issue for the web app which is deployed on AWS lambda.

Usage

Requirements

Deployment

  • Clone this repo.
$ git clone https://github.com/mattdamon108/lambda-warmer.git
  • Rename serverless.template.yml to serverless.yml and configure it with your IAM profile.
$ mv serverless.template.yml serverless.yml
service: lambda-warmer

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: ap-northeast-2 # Edit the region
  profile: your-profile # Edit here with your AWS IAM profile
  memorySize: 128
  timeout: 15s

functions:
  warmer:
    handler: handler.warmer
    events:
      - schedule: rate(5 minutes)

Your IAM profile needs to be stored in ~/.aws/credentials with proper permissions to create a lambda function through AWS cloudformation.

  • Set the target URL
// handler.js

module.exports.warmer = async (event, context, callback) => {
  try {
    await warming("https://www.rate-link.com/rates"); // change your target URL
    context.succeed();
  } catch (e) {
    context.done();
  }
};
  • Deploy
$ sls deploy

About

A lambda function to warm another lambda function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published