DEV Community

Cover image for Deploying My Probot App to a Serverless Lambda
Rizèl Scarlett for GitHub

Posted on

Deploying My Probot App to a Serverless Lambda

I built a Probot application, but I’m currently using to test webhooks, and I’m running the application locally. Now that my app is production-ready, I want to deploy it to a lambda. There are multiple platforms you can use to deploy your application to a lambda, but I prefer AWS because I’m most familiar with it.

AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of the Amazon Web Services. AWS Lamba additionally manages the computing resources required for the code and adjusts those resources in conjunction with incoming events.

Below are the steps I took to deploy my Probot app to a Lambda.

  • Login or create an account on AWS Console
  • Run npm install @probot/adapter-aws-lambda-serverless. This npm package is an adapter to run a Probot application function in AWS Lambda using the Serverless Framework.
  • Run npm install serverless -g to interact with the Serverless Framework CLI
  • Create a handler.js file at the root of your project and add the lines below to the file:

Image description

  • In your parameter store, create and store values for your app id, private key, and webhook secret

Image description

  • Create a serverless.yml file at the root of your project and add the following lines. Change the values for the service name and runtime to fit your use case. Please note that the environment variables for the webhook secret, app id, and private key are referenced here:

Image description

  • Create an IAM user. You will need to grant the right permissions to this user. Additionally, for the credential type, choose Access key - Programmatic access

Image description

  • Once you create the user, AWS will generate an access key ID and a secret access key. Store those credentials in a place you can remember.
  • Configure your AWS profile with the credentials you received by running this command in your terminal. This guide provides alternate methods to use AWS credentials.

    serverless config credentials \
      --provider aws \
      --key YourAWSKeyIdHere \
      --secret YourAWSSecretAccessKeyHere
  • Run sls deploy. This command deploys your entire service via CloudFormation. It will return a POST URL endpoint similar to this one:

    https://[random alphanumeric string]
  • Check that you successfully deployed your lambda

Image description

  • Update your webhook URL and your homepage URL to the lambda’s endpoint URL

Image description

After following these steps, your app should work without running it locally and you can read the logs for your application in AWS CloudWatch.

Want to learn more about automating with GitHub? Follow GitHub and me (@blackgirlbytes) on DEV for more content. I'll try to post daily!

Top comments (1)

andresdiegolanda profile image

Great article. Just one question. Where do you get the Webhook URL for the last step?

Many tks!