forked from TransparentHealth/smh_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·46 lines (41 loc) · 1.57 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# import logging
import os
import sys
from smh_app.ssmenv import EC2ParameterStore
import dotenv
from getenv import env
from smh_app.settings import EC2PARAMSTORE_4_ENVIRONMENT_VARIABLES # , DEBUG
AWS_DEFAULT_REGION = env('AWS_DEFAULT_REGION', 'us-east-1')
VPC_ENV = env('VPC_ENV', 'dev')
VPC_APP_NAME = env('VPC_APP_NAME', 'smhapp')
PARAMETER_STORE_PATH = "/%s/%s/" % (VPC_ENV, VPC_APP_NAME)
if __name__ == '__main__':
# (in dev)
# logging.basicConfig(
# level=DEBUG and 10 or 20,
# format="{asctime} {levelname} {name}:{lineno} | {message}",
# style="{",
# )
# Defaulting to .env
# Get this from .env file from your local development environment or
# Ansible,
dotenv.load_dotenv()
ENVIRONMENT_VARIABLE_STRATEGY = ".ENV"
# EC2 Parameter Store
try:
if EC2PARAMSTORE_4_ENVIRONMENT_VARIABLES == "EC2_PARAMSTORE":
parameter_store = EC2ParameterStore(region_name=AWS_DEFAULT_REGION)
django_parameters = parameter_store.get_parameters_by_path(
PARAMETER_STORE_PATH, strip_path=True
)
EC2ParameterStore.set_env(django_parameters)
ENVIRONMENT_VARIABLE_STRATEGY = EC2PARAMSTORE_4_ENVIRONMENT_VARIABLES
except Exception as e:
print("Exception", e)
# print(
# 'ENVIRONMENT_VARIABLE_STRATEGY in manage.py is', ENVIRONMENT_VARIABLE_STRATEGY
# )
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smh_app.settings')
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)