Serverless Webhooks is a small python project that digests webhooks from services that don't easily support push notifications and turns them into Pushbullet pushes. Depending on the number of events this project should fit under the free tier on AWS.
At this stage it supports GitHub, Discourse and Mailerlite webhooks inbound and only Pushbullet for notifications. Eventually I would like to move the Pushbullet code out to be more portable and support other platforms.
This project uses AWS SSM environment variables to store secret tokens. A below example shows how to store them using the AWS CLI tools:
aws ssm put-parameter --name /hooks/pushbullet_api_key --value <secure token in here> --type SecureString
Install serverless
and serverless-python-requirements
:
npm install -g serverless
sls plugin install serverless-python-requirements
Install python requirements
Note: Its highly suggested you install the python requirments inside a virtualenv!
pip install -r requirements.txt
Now login to Pushbullet and generate an access token. This access token should be store as a SSM variable under /hooks/pushbullet_api_key
.
Now deploy your Serverless gateway:
sls deploy
- Generate a secret token
You could useruby -rsecurerandom -e 'puts SecureRandom.hex(20)'
- Add your secret to AWS SSM under
/hooks/github_secret
eg:aws ssm put-parameter --name /hooks/github_secret --value a3f7b3d530ab15e2f07df0324f8255cfcade49cd --type SecureString
- Confirm your gateway that serverless created above (check it via
sls info
) - Go to your repository settings -> Webhooks.
- Add a new webhook:
- Payload URL -> Your serverless POST endpoint for GitHub
- Content Type ->
application/json
- Secret -> The secret you generated above
- Events -> The events configured in
config.yaml
- Click add Add Webhook!
If you've done everything above correctly you should recieve a Ping event from GitHub via Pushbullet.
- Generate a secret to sign the payloads with
You could use
ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'
- Add your secret to AWS SSM under
/hooks/discourse_secret
eg:aws ssm put-parameter --name /hooks/discourse_secret --value a3f7b3d530ab15e2f07df0324f8255cfcade49cd --type SecureString
- Confirm your gateway that serverless created above (check it via
sls info
) - Go to the Discourse Admin interface -> API -> Webhooks -> New Webhook
- Enter your settings into Discourse:
- Payload URL for the Discourse endpoint (
/v1/discourse
) - Content-Type ->
application/json
- Secret -> the one you generated above
- Payload URL for the Discourse endpoint (
If you've done everything above correctly try and send a ping event to your Discourse endpoint!
Doco coming!
Licence: MIT