A specially crafted AWS CDK template that is designed as a reference for a fully serverless application
Simple, clean, and easy to get started with your custom requirements.
- Designed for beginners to quickly get started with AWS CDK.
- Uses python for the lambda backend and typescript for 'infrastructure as a code'.
- Stuck how to integrate AWS services with CDK? Or how to setup a python lambda testing and deployment pipeline? This template is for you to refer!
-
Fork repo & clone
git clone https://github.com/<USERNAME>/cdk-poc.git cd ./cdk-poc
-
Setup python virtual environment
pipenv install --dev
dont have pipenv? checkout pipenv installation guide.
-
Develop:
- For changes in AWS deploy stack, navigate to
deploy
install npm packagescd ./deploy/
You can edit the template stack inyarn
deploy/lib/cdk-poc-stack.ts
. In this file, we can create infrastructure as code, for reference check out AWS CDK documentation - For changes in Lambda functions, navigate to
src/functions
Here you will find two template functionscd ./src/functions/
Producer
andConsumer
You can edit/add/delete your own lambda functions here, just ensure that they are referred in the stack file mentioned above Note that lambda layer creation is taken care in CI workflow so you need not worry about it.
- For changes in AWS deploy stack, navigate to
-
Test:
-
Template uses pytest with moto to mock aws environment to run the tests
pipenv run python -m pytest ./src/tests/
-
To generate a coverage report
pipenv run python -m pytest ./src/tests/ --cov=. --cov-report=html
-
Run Linter
pipenv run python -m flake8 ./src
-
-
Deploy: In order to use the CI workflow we need these three github repo secrets
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
checkout how to find access & secret keys
once these are configured, we can simply push / merge on the main branch which will trigger a CI workflow to build, test and deploy stack on aws. The workflow will generate a artifact named
aws-artifacts
which can be downloaded post workflow run.For pull requests, CI workflow will only build and test, and not deploy.
-
Destroy: In order to destroy/takedown the deployed stack in your AWS account, you can manually run the teardown workflow. It destroys all the resources created under the
cdk-stack
file.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.