Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wagtail on AWS Lambda, with Zappa

Wagtail on AWS Lambda, with Zappa

Install Wagtail and Zappa, and create an empty site:

pip install wagtail zappa zappa-django-utils
pip install pip==9.0.3 # see
wagtail start foo

Set up Zappa. Set the project settings to Make a note of your bucket name.

cd foo
zappa init

Allow all hosts for now, and include zappa_django_utils in your INSTALLED_APPS:

echo -en "\n\nALLOWED_HOSTS = ['*']" >> foo/settings/
echo -en "\n\nINSTALLED_APPS += ('zappa_django_utils',)" >> foo/settings/

Add Zappa's SQLite backend to foo/settings/

    'default': {
        'ENGINE': 'zappa_django_utils.db.backends.s3sqlite',
        'NAME': 'sqlite.db',
        'BUCKET': 'your-bucket-name'

Deploy the site, migrate the database and create an admin user:

zappa deploy dev
zappa manage dev migrate
zappa manage dev create_admin_user

Finally set up static files:

pip install django-storages boto

Add and configure django-storages, in settings/foo/

INSTALLED_APPS += ('storages',)
# use the bucket that was created in `zappa init`
AWS_STORAGE_BUCKET_NAME = 'your-bucket-name'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
# Don't do this! It's convenient but insecure to use the same 
# bucket for static files and media.
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

Update and collect static.

zappa update dev
zappa manage dev "collectstatic --noinput"

Fonts probably won't work until you set a CORS policy on your bucket. Go to your S3 bucket properties, and under "Permissions", click on "Add CORS Configuration", and replace the contents with:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.