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.
- npm
- Docker (optional but recommended)
- Copy .env.example to .env
- Check DATABASE points to valid MongoDB URI (mongo setup)
- Install NPM dependancies
npm install
- Test
# run test via local docker containers
npm test
# clean up containers
npm run cleanup
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
to127.0.0.1:xxxxx
wherexxxxx
is new port. - Update .env connection string with new port
- This can be ran manually, or updated in
package.json
for ongoing convenience
- 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
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.