Bitbucket2SNS transforms Bitbucket webhook requests into AWS SNS -notifications, making it easy to integrate with other AWS services, for example run Lambda function on every commit.
Install recent Node (v6.10 preferred) and Serverless packages. Usage of nvm
is encouraged.
# Install Node and Serverless
nvm use v6.10
npm install -g [email protected]
sls --version
# Clone and init codebase
git clone https://github.com/juhamust/bitbucket2sns.git
cd bitbucket2sns/
npm install
# Edit settings if needed
vim env.yml
# Deploy
sls deploy --profile=my-aws-profile
# Output (copy endpoint address)
> Service Information
> service: bitbucket2sns
> stage: dev
> region: eu-central-1
> api keys:
> None
> endpoints:
> POST - https://123123.execute-api.eu-central-1.amazonaws.com/dev/webhook
> functions:
> webhook: bitbucket2sns-dev-webhook
- Open Bitbucket repository (that you want to send webhook requests to AWS) settings
- Open webhook -section in Bitbucket repository: Settings > Integrations > Webhooks
- Click Add webhook and paste the collected URL and set the authentication token as
?token=<tokenvalue>
(usage of token is optional but recommended). Example:https://123123.execute-api.eu-west-1.amazonaws.com/dev/webhook?token=secret
- You can test the functionality by committing a new change set. Bitbucket webhook requests can be reviewed after sending in View requests.
- You can see the Lambda logs in AWS CloudWatch
Once you've setup Bitbucket - SNS properly configured, you can start using it. Following snippet shows how to trigger a lambda on notification.
- Go to Lambda -service
- Start new Lambda with Create a Lambda function
- Type in the code (see example)
- Use
bitbucket-sns
as event source - See Monitoring section for lambda logs
'use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
const message = event.Records[0].Sns.Message;
console.log('From SNS:', message);
callback(null, message);
};
- Support for Serverless 1.x
- Added unit testing
- Initial release
MIT -licensed