Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 2.3 KB

File metadata and controls

70 lines (58 loc) · 2.3 KB

lambda-snshook.js

AWS Lambda function using CUCloud.plugins.gitHubHookSns to maintain "Amazon SNS" service hook on all repositories for a GitHub organization.

Features

  • Rotates AWS keys on your hook when your configured access key changes.

Required

Installation

  1. Follow the standard installation steps defined in README.md.

  2. Create your config config-sns-hook.yml and update the values as appropriate:

    plugin.sns-hook:
      gitHubOrgName: OrgName
      oAuthToken: token
      snsHook:
        events:
          - push
        name: amazonsns
        config:
          sns_topic: 'arn'
          aws_secret: 'secret'
          aws_key: 'key'
        active: true
  3. Import your configuration values to a profile of your choice:

    cucloud-js-schema import config-sns-hook.yml [--profile <profile-name>]
  4. IAM: Create the lambda-sns-hook policy. Be sure to note the policy ARN created. You will use it later

    aws iam create-policy --policy-name lambda-sns-hook-policy --policy-document file://<LOCAL PATH>/lambda-sns-hook-policy.json
  5. IAM: Create the lambda-sns-hook role with the appropriate trust policy

    aws iam create-role --role-name lambda-sns-hook-role --assume-role-policy-document file://<LOCAL PATH>/lambda-cucloud-trust.json
  6. IAM: Attach the policy to the role

    aws iam attach-role-policy --role-name lambda-sns-hook-role --policy-arn <enter policy arn here>
  7. Prepare your Lambda Deployment directory:

mkdir lambda-snshook
cd lambda-snshook
npm install <REPLACE-WITH-PATH-TO-YOUR-CUCLOUD-CLONE>
# ex. npm install ~/Desktop/cucloud-js
cp node_modules/cucloud/examples/lambda-snshook.js index.js
  1. Manually set the profile name in your lambda function If/when AWS Lambda supports environmental variables, this step will be unnecessary.
# update your index.js
nano index.js
  1. Create the ZIP and create your lambda function, specifying the IAM Role: lambda-sns-hook-role
    zip -r ../lambda-snshook.zip . *