This repository allows one to quickly create a Flask service. The service can be run locally in a Docker container and then easily deployed to AWS Lambda.
git clone
the repo that uses this as a templategit submodule init
orsync
orupdate
, I'm not sure which works but I don't think running all of them hurts!./scripts/start_containers.sh
- Note: If you run into an issue related to a file in housekeeping_flask/ being recognized as a directory instead of a file, you probably tried to start the containers before getting the submodule contents. Redownload the submodule, prune you containers, and volumes and retry.
- To show submodules:
git config --file=.gitmodules -l
(from https://tech.serhatteker.com/post/2019-01/changing-git-submodules-urlbranch-to/) - To update which version of a submodule this repo expects:
cd
to submodule- With changes in the submodule,
git add
,git commit
, andgit push
like normal. cd
back to the root of this repository, one level above the submodulegit add housekeeping_flask/
git commit -m 'update housekeeping_flask version;'
git push
Note: ./scipts/deploy
should work after the first deployment and if the containers are running. If not, follow the below steps.
From the root of the Git repo.
git status
: Make sure you're on master!- Stop containers.
- Start containers.
docker exec -it public_api bash
cd /usr/src/public_api
python3 -m venv venv
source ./venv/bin/activate
pip install zappa
pip install -r requirements.txt
zappa package -s zappa_settings.yaml -o out.zip
exit
to get out of the container.cd my_api/
:zappa deploy -z out.zip -s zappa_settings.json
- NOTE: The first time you deploy using
zappa deploy
with-z out.zip
it'll fail because the IAM Execution role doesn't exist. This is a bug with zappa. To fix, first dozappa deploy
without-z out.zip
. Zappa will create the execution role, though the command will fail. The command output will have a line like: ```
Creating documentguardian-public-api-dev-ZappaLambdaExecutionRole IAM Role.. Creating zappa-permissions policy on documentguardian-public-api-dev-ZappaLambdaExecutionRole IAM Role.
After that, `zappa deploy -z out.zip -s zappa_settings.json ` should pass.
- NOTE: The first time you deploy using