A lambda worker for sending queued emails at scheduled times.
This repository doesn't follow typical project structure, so a word of explanation is required.
cdkdirectory contains TypeScript code to deploy the worker to AWS Cloud.workerdirectory contains Python code (project).- root directory contains main
.gitignore,.pre-commit-config.yaml, license and readme .githubcontains CI/CD pipelines.
This project is for Python 3.12 version.
To work on Python code you should install Poetry.
Then you can create the Poetry environment:
$ cd worker/
$ poetry installImportant! Once Python dependencies are installed, you must install pre-commit configuration:
$ cd worker/
$ poetry shell
$ cd .. # to root directory
$ pre-commit installThis project is for Node 18 LTS version.
To work on CDK (Cloud Development Kit) for AWS Cloud you should install:
- node JS (a suggested method is to use nvm)
- cdk:
$ cd cdk/ $ npm install
Additionally you will probably want to set up your AWS CLI and credentials.
More instructions available in cdk/README.md file.
AWS lambda environment is specific when it comes to Python path management. For example,
despite the code being in worker directory, lambda Python environment doesn't
recognize worker module.
Therefore it's important to avoid using from worker.xyz import asd or
import worker.utils, because this will not work. Instead, assume that the environment
is stored in unnamed directory somewhere on a virtual machine, and you only have access
to worker's submodules, like utils. Thus from utils.typing import Settings will
work.
Apart from unit tests, you can deploy the lambda to the staging environment and test it in AWS web console.
To deploy lambda use CDK:
$ cd cdk/
$ cdk deploy EmailWorkerLambdaStagingWarning: this circumvents the CI/CD pipeline.