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.
The folder ./.docker folder contains the dev containers as well as the travis production containers. .env.example must be populated when running in development as per the process below.
- Docker
- docker-compose
- npm
- Copy .env.example to .env
- Update ENVIRONMENT to "development"
- Change TESTFILE location if desired
- Install NPM dependancies
npm install
- Init Docker
# use docker to run test
docker-compose -f ./docker-compose.yml -f ./.docker/docker-compose.dev.yml up --exit-code-from app
# clean up containers
docker rm -v sendgrid-eventkit-lambda-mongodb-mongo
- This will run the lambda function with the 'event' argument data overwritten from the TESTFILE json.
- docker exits when lambda function returns code (sendgrid_app_1 exited with code ~)
- ~ = 0 = success;
- 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.