Body Fat Calculator
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Deployment shortcuts

  • Compile and run locally:
source .env3/bin/activate
cd django
python collectstatic
python runserver
  • Deploy to AWS Lambda:
source .env3/bin/activate
cd django
zappa update dev
  • Sync static assets to AWS S3:
aws s3 sync static/ s3://

Environment and Infrastructure Setup

Django Build

pip install awscli
source .env3/bin/activate
django-admin startproject app   # create a new project named app
cd app
python runserver  # to verify that django installed and initialized correctly
python startapp bmi   # create the BMI web app
pip install -r requirements.txt
python bower install

Zappa AWS deployment manager setup

  • Note that Zappa relies an IAM user which is specified in django.zappa_settings.json. I placed a copy of the IAM policy in json format in aws-iam-policy.json.
  • When I had to manually add the VPC settings to zappa_settings.json. I never figured out the individual policy permissions for this and so ended up temporarily adding admin rights to the project's IAM user.
  • Ensure that the RDS MySQL database uses IAM access rather than traditional username / pwd.
  • Manual deployment steps
    • Enable CORS in AWS API Gateway. this is necessary for Fontawesome files.
    • add VPC settings to zappa_settings.json
zappa init         # see notes below on installation details
zappa deploy dev   # Deploy app to AWS
zappa undeploy dev # Delete from AWS
zappa update dev   # update existing app to AWS
zappa manage dev "collectstatic --noinput"    # collect static assets
zappa tail         # view Lambda execution log
zappa -h

Stack References

  • DATABASES: changed settings to AWS RDS MySQL. config settings are stored locally in mysite/.env
  • ALLOWED_HOSTS: added FQDN's for and per suggestions in the Django - Zappa Guide
  • SECRET_KEY: moved to locally-stored .env file
  • DEBUG: moved to locally-stored .env file