aws.py 2.3 KB
Newer Older
1 2 3 4 5 6
"""
This is the default template for our main set of AWS servers.
"""
import json

from .common import *
7
from logsettings import get_logger_config
8 9 10 11 12 13 14 15 16 17 18 19 20 21
import os

# specified as an environment variable.  Typically this is set
# in the service's upstart script and corresponds exactly to the service name.
# Service variants apply config differences via env and auth JSON files,
# the names of which correspond to the variant.
SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)

# when not variant is specified we attempt to load an unvaried
# config set.
CONFIG_PREFIX = ""

if SERVICE_VARIANT:
    CONFIG_PREFIX = SERVICE_VARIANT + "."
22

John Jarvis committed
23
############### ALWAYS THE SAME ################################
24 25 26 27 28 29 30
DEBUG = False
TEMPLATE_DEBUG = False

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

John Jarvis committed
31
############# NON-SECURE ENV CONFIG ##############################
32
# Things like server locations, ports, etc.
33
with open(ENV_ROOT / CONFIG_PREFIX + "env.json") as env_file:
34 35
    ENV_TOKENS = json.load(env_file)

36
LMS_BASE = ENV_TOKENS.get('LMS_BASE')
37

38 39 40 41 42 43
SITE_NAME = ENV_TOKENS['SITE_NAME']

LOG_DIR = ENV_TOKENS['LOG_DIR']

CACHES = ENV_TOKENS['CACHES']

44 45
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')

46 47 48
for feature, value in ENV_TOKENS.get('MITX_FEATURES', {}).items():
    MITX_FEATURES[feature] = value

49 50
# load segment.io key, provide a dummy if it does not exist
SEGMENT_IO_KEY = ENV_TOKENS.get('SEGMENT_IO_KEY', '***REMOVED***')
51

52 53 54
LOGGING = get_logger_config(LOG_DIR,
                            logging_env=ENV_TOKENS['LOGGING_ENV'],
                            syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
John Jarvis committed
55 56
                            debug=False,
                            service_variant=SERVICE_VARIANT)
57

John Jarvis committed
58
################ SECURE AUTH ITEMS ###############################
59
# Secret things: passwords, access keys, etc.
60
with open(ENV_ROOT / CONFIG_PREFIX + "auth.json") as auth_file:
61 62
    AUTH_TOKENS = json.load(auth_file)

63 64
AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
65 66
DATABASES = AUTH_TOKENS['DATABASES']
MODULESTORE = AUTH_TOKENS['MODULESTORE']
67
CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE']
68 69

# Datadog for events!
Chris Dodge committed
70
DATADOG_API = AUTH_TOKENS.get("DATADOG_API")