Deploying My Probot App to a Serverless Lambda

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 appli…


This content originally appeared on DEV Community and was authored by Rizel Scarlett

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:

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].execute-api.us-east-1.amazonaws.com/dev/api/github/webhook
    
  • 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!


This content originally appeared on DEV Community and was authored by Rizel Scarlett


Print Share Comment Cite Upload Translate Updates
APA

Rizel Scarlett | Sciencx (2022-02-15T23:06:33+00:00) Deploying My Probot App to a Serverless Lambda. Retrieved from https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/

MLA
" » Deploying My Probot App to a Serverless Lambda." Rizel Scarlett | Sciencx - Tuesday February 15, 2022, https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/
HARVARD
Rizel Scarlett | Sciencx Tuesday February 15, 2022 » Deploying My Probot App to a Serverless Lambda., viewed ,<https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/>
VANCOUVER
Rizel Scarlett | Sciencx - » Deploying My Probot App to a Serverless Lambda. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/
CHICAGO
" » Deploying My Probot App to a Serverless Lambda." Rizel Scarlett | Sciencx - Accessed . https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/
IEEE
" » Deploying My Probot App to a Serverless Lambda." Rizel Scarlett | Sciencx [Online]. Available: https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/. [Accessed: ]
rf:citation
» Deploying My Probot App to a Serverless Lambda | Rizel Scarlett | Sciencx | https://www.scien.cx/2022/02/15/deploying-my-probot-app-to-a-serverless-lambda/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.