Skip to content

Latest commit

 

History

History
96 lines (67 loc) · 3.35 KB

File metadata and controls

96 lines (67 loc) · 3.35 KB

sendgrid-eventkit-lambda-mongodb

Build Status Open Issues License: MIT

Table of Contents

Motivation

Provision a Lambda based relay script that will, self test, self deploy and consume SendGrid webhook endpoints and relay them to Mongodb's Atlas cloud service. Also included as part of the microservice is information on how to setup the AWS IAM policies with the least permissive policy possible. The service is deployable using the Travis github hooks and will automatically test with local integrations of NodeJS and MongoDB that are stored within the docker containers.

Local Dependancies

  1. npm
  2. Docker (optional but recommended)

Process

  1. Copy .env.example to .env
  2. Check DATABASE points to valid MongoDB URI (mongo setup)
  3. Install NPM dependancies
npm install
  1. Test
# run test via local docker containers
npm test
# clean up containers
npm run cleanup

Mongo Setup

You can set the DATABASE environment variable to any valid Mongo connection URI.

However, it is recommend you test to a local isolated Mongo instance.

Via provided NPM script:

npm run setup-mongo

Via Docker directly:

docker run --detach --name sendgrid-mongo --expose 27017 -p 127.0.0.1:27017:27017/tcp mongo

To change local port due to any conflicts:

  • Update 127.0.0.1:27017 to 127.0.0.1:xxxxx where xxxxx is new port.
  • Update .env connection string with new port
  • This can be ran manually, or updated in package.json for ongoing convenience

Pending updates

  • enforce unique index on sg_message_id
  • handle unique key errors in insertMany
  • replace vagrant with docker for local development
  • add packaged staging with Docker
  • improve debug testdata files with unique event ids
  • add testing and travis CI
    • test deep nested lambda function handlers (Result: namespace/component.handler)
    • setup IAM user for Travis
    • document Travis:IAM process
    • set up travis build file using docker
    • add Lambda deployment to travis (https://docs.travis-ci.com/user/deployment/lambda/)
  • document AWS API Gateway setup

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT