Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@probot/adapter-aws-lambda-serverless

Package Overview
Dependencies
Maintainers
7
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@probot/adapter-aws-lambda-serverless

An extension for running Probot in AWS Lambda

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

@probot/adapter-aws-lambda-serverless

Adapter to run a Probot application function in AWS Lambda using the Serverless Framework

Build Status

Usage

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(),
});

Configuration

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: post

Make sure to configure your GitHub App registration's webhook URL to <your lambda's URL>/api/github/webhooks.

Test deployment

For testing your Probot deployment without end to end (GitHub) integration, you can use this shell snippet:

$ LAMBDA_URL=https://x.execute-api.y.amazonaws.com/stage-or-basePath/api/github/webhooks
$ SECRET=the_webhook_secret
$ TMP_DATA_FILE=/tmp/smoke.data

$ echo -n "{\"action\":\"test\"}" > $TMP_DATA_FILE
$ SIGN=$(openssl dgst -sha1 -hmac $SECRET $TMP_DATA_FILE | cut -d" " -f2)
$ curl --request POST --header "X-Hub-Signature: sha1=$SIGN" --header "X-Github-Event: test" --header "X-GitHub-Delivery: fake" --data-binary "@$TMP_DATA_FILE" $LAMBDA_URL
{"ok":true}        <-- Concent for Probot v10: {"message":"Received test.test"}

Examples

Add yours!

Common errors

Http CodeMessageDescription
403Missing Authentication TokenBad endpoint (this one is not binded on Lambda)
500Internal server errorIncorrect headers value (X-GitHub-Delivery, X-GitHub-Event, X-Hub-Signature) or Probot error

Probot v11 migration key points

For Probot v11 support, this adapter introduces significant changes. Here the key points to update (in addition of Probot v11 breaking changes):

Key point / Probot<= v10>= v11
NPM package name@probot/serverless-lambda@probot/adapter-aws-lambda-serverless
handler.js contentSee Usage v1.xSee Usage
AWS Lambda Runtimehandler.probothandler.webhooks
AWS Lambda HandlerNode.js 12.x (preferred)Node.js 12.x (required)

LICENSE

ISC

Keywords

FAQs

Package last updated on 09 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc