Node.js Lambda that automatically emails a file from a given Dropbox folder. Also sends a text message via AWS SNS to verify an email has been sent.
- Dropbox JS SDK
- AWS CDK
- Other AWS services such as Lambda, SES, SNS and S3
- Sentry - Optional Error tracking
- Node & nvm
- AWS CDK - for deployment to AWS
The application was made for a very specific use case, however the general problem it solves is to automate sending an invoice to a client.
This invoice is usually handwritten, scanned and uploaded to Dropbox. In the past, this would be then manually sent via email.
This application rectifies this by checking if the file has been uploaded to Dropbox and proceeds to generate the email and send it to the specific client as an email with an attachment, based on the uploaded file name prefix.
The application checks for the file every so often using a cron. These settings could be changed and the cron could be ditched in favor of a webhook connected to the particular Dropbox folder.
npm installto install CDK deps- Set environment variables in
variables.env - Set at least one
person.jsonindatafolder cd srcfor lambda codenpm installnpm start
Run these from the root directory
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template
Once .env vars set correctly:
export $(cat .env | xargs) && cdk synthexport $(cat .env | xargs) && cdk deploy
Note that there is a script to move files from your local machine to S3, to run this you will need the AWS-CLI installed and connected to your AWS account
To run it simply use npm run copy-data