This is the template for a new cloud service on AWS. After bootstrapping, you will have a complete production-grade repo for a basic service (hello world lambda).
We want all our cloud services to be consistent and easy to work on. The basic idea of this template is to give you a ready-to-go repository, where you can use make
to easily perform all relevant tasks (build packages, run tests, deploy, etc.), while having a standard deployment pipeline that is well-tested and understood. We also include all the best practices and goodies we like to use, such as pre-commit, a PR template, etc.
Specifically, this template contains:
- python source code and unit tests for hello world lambda
- terraform for IaC deployment to AWS
- component tests targeting deployed service on AWS
- Circle CI Pipeline to test and deploy service all the way to production
- Docker image for running CI pipeline
- Makefile for running all service commands
- pre-commit, github templates, and other goodies
After creating a new repo, search for FIXME
s and replace them accordingly. The main things to replace:
- dev and prod slack channel IDs for notifications (
dynamic_config.yml
) - Docker repository for the CI image (
dynamic_config.yml
) - Service name (
variables.tf
) - S3 bucket, DynamoDB table, and service prefix for terraform remote backend for dev and prod (
dev/prod-backend.tfvars
)
- We use CircleCI for our pipelines. If you use something else, you'll have to build your own pipeline (we'd love to see a P/R for that). It should be relatively straightforward, since
make
does the bulk of the heavy lifting. The CI pipeline mainly chainsmake
calls together.
We welcome contributions to improve this template, in the form of Pull Requests or Issues.
When you're finished setting up your repo, you can use the text below as a starting point for its README
Briefly describe service here. Example: The cloud-template provides a starting point repository for new cloud services.
- All operations are done with make. It should already be installed. Otherwise:
brew install make
- Deployment is managed via terraform:
brew install terraform
(protip: install withtfenv
) - We use pre-commit hooks. If you don't pre-commit installed, it can be installed with pip (
pip install pre-commit
)- Once you have pre-commit installed, run the following command to install the repository hooks:
pre-commit install --install-hooks
- Once you have pre-commit installed, run the following command to install the repository hooks:
- Helper scripts are written in Python and managed with Poetry:
brew install python@3.y
(protip: install withpyenv
instead)pip install poetry
(protip: install withpipx
instead)
- To setup dependencies:
make install
- To run unit tests:
make unit-tests
- To build lambda packages:
make build
- To plan deployment:
make plan
- To deploy infrastructure:
make deploy
- To run component-tests:
make component-tests
- To destroy deployed infrastructure:
make destroy
You can call make help
to see all available targets.
Major things, if any, that anyone checking out the repo should know about. Example: when making changes to the template, please create a quick example service to make sure everything is still working out of the box.