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 install
to install CDK deps- Set environment variables in
variables.env
- Set at least one
person.json
indata
folder cd src
for lambda codenpm install
npm start
Run these from the root directory
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
Once .env
vars set correctly:
export $(cat .env | xargs) && cdk synth
export $(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