Example of a flask app using dynamodb to serve as an api
Steps to make this work in Zappa
-
Create a user in IAM and get Access Keys (or use your current AccessKeys)
-
If you haven't done it before then install AWSCLI (pip install awscli)
-
Run
aws configure
and set your access keys and the region you would like to use for you DynamoDb -
Write and test your Flask code (provided here)
4a. ensure it is reading and writing to your DynamoDb -
create virtualenv (you may need to
pip install virtualenv
)
5a. for windowspython -m venv \zappenv
5b for macvirtualenv zappaenv
-
activate your virtualenv
6a. for Windows\zappenv\Scripts\activate.bat
6b. for Macsource ./zappaenv/bin/activate
-
install requirements.txt
pip install -r requirements.txt
(note) you may need to update pip and remember to include any additional requirements you have added. to update pip typepython -m pip install --upgrade pip
if you have to upgrade pip you will need to install requirements again.run
pip install zappa --upgrade
(This is not mentioned in the video)* -
run
zappa init
you are almost always 'ok' if you except the defaults, but you can change them (note) you should see a "zappa_settings.json" file appear in your directory. -
run
zappa deploy dev
This is assuming you used the default -
When this complete you will given a url, that will be running in AWS!
Assuming you have to (or just want to) update your flask application.
- Make and test your changes locally
- run
zappa update dev
We are not doing this any longer!