AWS lambda functions designed to extend SWB functionality.
- Notification to user on account creation, via SES
- path:
notification/user
- lambda name:
swb-tools-user-notification-<stage>
- requires: lodash layer
- path:
- Notification to admin on user account creation, via SNS
- path:
notification/admin
- lambda name:
swb-tools-admin-notification-<stage>
- requires: lodash layer
- path:
- Notification when a user's cost exceeds given threshold, via SNS
- path:
notification/billing
- lambda name:
swb-tools-billing-notification-<stage>
- path:
This repository uses Node version 16, pnpm, and serverless.
-
Setup node version 18 using nvm and update npm. Optional
nvm install 18 npm install -g npm@latest
-
Install pnpm, configure shell environment, and update.
Note: PNPM is used as the main package manager and it's referenced in some of the serverless files. If you want to change this to a different package manager, you'll have to remove all the pnpm lock files and replace references to pnpm locally. It is reccomended to not change the package manager for the individual lambda layers from NPM, as this could result in unusual behavior for package imports.
npm install -g pnpm pnpm setup pnpm add -g pnpm
-
Update your AWS credentials for deployments.
vi ~/.aws/config vi ~/.aws/credentials export AWS_PROFILE=<profile name>
-
Create and/or update the config file for the stage you're deploying.
cp configs/stage.example.yml configs/stage.<stage>.yml vi configs/stage.<stage>.yml
-
Deploy lambda layers, if there are changes or they don't already exist.
cd layers pnpm install pnpm sls deploy
Move into the folder for the lambda you'd like to work with. Example, cd notification/admin
.
Run unit tests on new lambda handler changes.
pnpm test
Test lambda locally with serverless emulation. (See serverless invoke local documentation for more specific instructions.)
pnpm sls invoke local \
--stage <stage> \
--function AccountRegistrationNotification \
--data <handler payload>
Preview serverless AWS cloudformation artifacts, using the package command. This will package the stack as it does for deployment; the package/artifacts are located in the .serverless
folder.
pnpm sls package --stage <stage>
To verify serverless parameter and variable resolution, run the print command.
pnpm sls print --stage <stage>
Deploy lambdas changes.
pnpm sls deploy --stage <stage>