Skip to content

a node.js lambda function that forwards codebuild events to slack via SNS

License

Notifications You must be signed in to change notification settings

Mindflash/tf-codebuild-sns-slack-module

 
 

Repository files navigation

tf-codebuild-sns-slack

a node.js lambda function that forwards CodeBuild events to Slack via SNS

architecture diagram

Installing

# clone the repo and install dependencies
$ git clone [email protected]:cludden/tf-codebuild-sns-slack.git

Contributing

  1. Clone it (git clone [email protected]:cludden/tf-codebuild-sns-slack.git)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes using conventional changelog standards (git commit -m 'feat(my-new-feature): Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Ensure linting/security/tests are all passing
  6. Create new Pull Request

Testing

Prerequisites:

# run test suite and generate code coverage
$ docker-compose run tf-codebuild-sns-slack

# run linter
$ docker-compose run tf-codebuild-sns-slack npm run lint

# run security scan
$ docker-compose run tf-codebuild-sns-slack npm run sec

Building

$ docker-compose run tf-codebuild-sns-slack

Releasing

  1. Merge fixes & features to master
  2. Run lint check npm run lint
  3. Run security check npm run sec
  4. Run full test suite docker-compose run tf-codebuild-sns-slack
  5. Run release script npm run release
  6. Push release & release tag to github git push --follow-tags
  7. Publish new release in github, using the release notes from the CHANGELOG

Configuring

Define custom configuration

{
  "slack": {
    "webhookUrl": "xxxx"
  },
  "log": {
    "level": "info"
  }
}

Add JSON configuration to ssm

$ aws ssm put-parameter --name /secrets/codebuild-sns-slack/custom --type SecureString --value $JSONCONFIG

Deploying

Via terraform

module "codebuild_trigger" {
  source                     = "git::[email protected]:cludden/tf-codebuild-sns-slack.git//terraform?ref={version}"
  additional_parameter_names = "/secrets/codebuild-sns-slack/custom"
  config_parameter_name      = "/secrets/codebuild-sns-slack"
  debug                      = ""
  memory_size                = 128
  name                       = "codebuild-sns-slack"
  node_env                   = "production"
  region                     = "us-west-2"
  s3_bucket                  = "my-artifact-bucket"
  s3_key                     = "tf-codebuild-sns-slack/${var.version}/index.zip"
  timeout                    = 10
}

License

Licensed under the MIT License

Copyright (c) 2017 Chris Ludden

About

a node.js lambda function that forwards codebuild events to slack via SNS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 64.0%
  • HCL 36.0%