This project has build on the GitOps principles, so this Git repo act as your Source of Truth.....Elaborate on DR, IAC,....
- Create an application bucket to hold all artefacts and documentation Set correct CORS for swagger....
- Add a custom domain name
- Add DLQ
- Add a post hook example
- Add a custom metric
- AWS CLI already configured with at least PowerUser permission
- Python 3 installed
- Pipenv installed
pip install --user pipenv
- Docker installed
- AWS SAM CLI installed
pip install --user aws-sam-cli
Provided that you have the requirements above installed, proceed by installing the application dependencies and development dependencies:
pipenv install
pipenv install -d
This project uses AWS Serverless Application Model (AWS SAM).
See Serverless Application Model (SAM) HOWTO Guide for more details in how to get started.
-
In your GitHub create a new repository named `workshop-lambda.
-
git init git add . git commit -m "Initial commit" git remote add origin [email protected]:bogguard/workshop-lambda.git git push -u origin master
Pytest
is used to discover tests created under tests
folder - Here's how you can run tests our initial unit tests:
make test
In order to run your code locally all dependencies need to be build and packaged on your local machine:
make build
Afterwards invoking your functions locally through a local API Gateway can be achieved by running:
make sam
If the previous command ran successfully you should now be able to hit the following local endpoint to invoke your functions:
http://localhost:3000/rest/one
http://localhost:3000/rest/two
In order to install the pipeline a GitHub token is required. To create a token go to: https://github.com/settings/tokens
Create a token with repo
and admin:repo_hook
permissions.
A pipeline is included in this stack in order to make it easy to deploy your code on AWS. The pipeline has 3 steps:
- Source: listen for Github code changes
- Build:
- clean the workspace
- lint your code and run unit tests
- package the code for deployment
- Deploy: deploy your code through CloudFormation on AWS
To install the pipeline run:
make create-pipeline OAUTH_TOKEN=your_github_token
To update the pipeline run:
make update-pipeline OAUTH_TOKEN=your_github_token
To remove the pipeline run:
make delete-pipeline
It is important that the Makefile created only works on OSX/Linux but the tasks above can easily be turned into a Powershell or any scripting language you may want too.
Find all available targets: make help