I built a Probot application, but I’m currently using smee.io 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:
- In your parameter store, create and store values for your app id, private key, and webhook secret
- 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:
- 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
- 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].execute-api.us-east-1.amazonaws.com/dev/api/github/webhook
Check that you successfully deployed your lambda
- Update your webhook URL and your homepage URL to the lambda’s endpoint URL
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)
Great article. Just one question. Where do you get the Webhook URL for the last step?
Many tks!