This project provides a working, open source based, Serverless cron jobs Python code including DEPLOYMENT code with CDK and a pipeline.
The project provides the following cron jobs:
- AWS EventBridge rule cron job that triggers a lambda every X minutes
- AWS EventBridge rule cron job that triggers a step function once a day at a specific time
- AWS EventBridge scheduler cron job that triggers a lambda once a day
The AWS Lambda function use a logger, metrics, tracing, environment variables parsing and input validation best practices.
This project can serve as a template for new Serverless cron jobs or a as a reference. - CDK deployment code, pipeline and handler are covered.
Contact details | [email protected]
- Python Serverless service with a recommended file structure.
- CDK infrastructure with infrastructure tests and security tests.
- CI/CD pipelines based on Github actions that deploys to AWS with python linters, static code analysis, complexity checks and style formatters.
- 3 different Serverless cron jobs including the new AWS EventBridge scheduler
- Unit, integration and E2E test folders ready for implementation.
The AWS Lambda handler will implement multiple best practice utilities.
Each utility is implemented when a new blog post is published about that utility.
The utilities cover multiple aspect of a production-ready service, including:
- Logging
- Observability: Monitoring and Tracing
- Observability: Business KPIs Metrics
- Environment Variables
- Input Validation
- Dynamic Configuration & feature flags
- Start Your AWS Serverless Service With Two Clicks
- CDK Best practices
- Docker - install Docker. Required for the Lambda layer packaging process.
- AWS CDK - Required for synth & deploying the AWS Cloudformation stack.
- Python 10
- poetry - Make sure to run
poetry config --local virtualenvs.in-project true
so all dependencies are installed in the project '.venv' folder. - For Windows based machines, use the Makefile_windows version (rename to Makefile). Default Makefile is for Mac/Linux.
- Run
make dev
- Run
poetry install
Create a cloudformation stack by running make deploy
.
CDK destroy can be run with make destroy
.
Run make pr
. This command will run all the required checks, pre commit hooks, linters, code formats, flake8 and tests, so you can be sure GitHub's pipeline will pass.
The command auto fixes errors in the code for you.
If there's an error in the pre-commit stage, it gets auto fixed. However, are required to run make pr
again so it continues to the next stages.
Be sure to commit all the changes that make pr
does for you.
CDK requires a requirements.txt in order to create a zip file with the Lambda layer dependencies. It's based on the project's poetry.lock file.
``make deploy` command will generate it automatically for you.
This file is used during GitHub CI to install all the required Python libraries without using poetry.
File contents are created out of the Pipfile.lock.
make deploy
make deps
commands generate it automatically.
Code contributions are welcomed. Read this guide.
Read our code of conduct here.
- Email: [email protected]
- Blog Website RanTheBuilder
- LinkedIn: ranisenberg
- Twitter: IsenbergRan
This library is licensed under the MIT License. See the LICENSE file.