Body Fat Calculator
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
django
keen_v1.3.1
.gitignore
README.md
aws-iam-policy.json
logo.key
package.json
requirements.txt

README.md

bodycalc.io

Deployment shortcuts

  • Compile and run locally:
source .env3/bin/activate
cd django
python manage.py collectstatic
python manage.py 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://bodycalc.io/static/

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 manage.py runserver  # to verify that django installed and initialized correctly
python manage.py startapp bmi   # create the BMI web app
pip install -r requirements.txt
python manage.py 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

settings.py

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