aws.py 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
"""
This is the default template for our main set of AWS servers. This does NOT
cover the content machines, which use content.py

Common traits:
* Use memcached, and cache-backed sessions
* Use a MySQL 5.1 database
"""
import json

11 12
from .logsettings import get_logger_config
from .common import *
13

14 15 16 17
############################### ALWAYS THE SAME ################################
DEBUG = False
TEMPLATE_DEBUG = False

18 19 20 21
EMAIL_BACKEND = 'django_ses.SESBackend'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

22 23
########################### NON-SECURE ENV CONFIG ##############################
# Things like server locations, ports, etc.
24
with open(ENV_ROOT / "env.json") as env_file:
25 26
    ENV_TOKENS = json.load(env_file)

27
SITE_NAME = ENV_TOKENS['SITE_NAME']
28

29 30 31
BOOK_URL = ENV_TOKENS['BOOK_URL']
MEDIA_URL = ENV_TOKENS['MEDIA_URL']
LOG_DIR = ENV_TOKENS['LOG_DIR']
32

33
CACHES = ENV_TOKENS['CACHES']
34

35
for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items():
36 37
    MITX_FEATURES[feature] = value

38
WIKI_ENABLED = ENV_TOKENS.get('WIKI_ENABLED', WIKI_ENABLED)
39

40
LOGGING = get_logger_config(LOG_DIR,
41 42 43
                            logging_env=ENV_TOKENS['LOGGING_ENV'],
                            syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
                            debug=False)
44

45

46 47
############################## SECURE AUTH ITEMS ###############################
# Secret things: passwords, access keys, etc.
48
with open(ENV_ROOT / "auth.json") as auth_file:
49 50
    AUTH_TOKENS = json.load(auth_file)

51 52
SECRET_KEY = AUTH_TOKENS['SECRET_KEY']

53 54 55
AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]

56
DATABASES = AUTH_TOKENS['DATABASES']