Adapter to run a Probot application function in AWS Lambda using the Serverless Framework
npm install @probot/adapter-aws-lambda-serverless// handler.js
const {
createLambdaFunction,
createProbot,
} = require("@probot/adapter-aws-lambda-serverless");
const appFn = require("./");
module.exports.webhooks = createLambdaFunction(appFn, {
probot: createProbot(),
});You need to add environment variables to configure Probot to your Lambda function. If you use the Serverless App, you can add parameters for APP_ID, PRIVATE_KEY, WEBHOOK_SECRET, the use these parameters in serverless.yaml.
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
environment:
APP_ID: ${param:APP_ID}
PRIVATE_KEY: ${param:PRIVATE_KEY}
WEBHOOK_SECRET: ${param:WEBHOOK_SECRET}
NODE_ENV: production
LOG_LEVEL: debug
functions:
webhooks:
handler: handler.webhooks
events:
- httpApi:
path: /api/github/webhooks
method: postMake sure to configure your GitHub App registration's webhook URL to <your lambda's URL>/api/github/webhooks.
- example-aws-lambda-serverless - Official example application that is continuously deployed to AWS Lambda
Add yours!