Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDS Instance Configurations #76

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions reporting/.env
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ CLIENT_SECRET=changeme
DB_PASSWORD=p@ssw0rd
FHIR_ID=trusted-client
FHIR_PASSWORD=secret
### Database ###
DATABASE_USERNAME=reporting
DATABASE_PASSWORD=0b39aca786e3
DATABASE_HOST=uat-reporting.cpmydgulhchj.us-east-1.rds.amazonaws.com
DATABASE_PORT=5432
DATABASE_NAME=openlmis_reporting
Binary file added reporting/config/.DS_Store
Binary file not shown.
Binary file added reporting/config/services/.DS_Store
Binary file not shown.
Binary file added reporting/config/services/nifi/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a
flowIdentifier=5aba1b21-32b5-462f-ae50-c49a6f975b57
flowVersion=5
flowVersion=5
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a
flowIdentifier=77a5e697-b3ae-4f91-8c4b-309bd3a5b82b
flowVersion=6
flowVersion=6
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a
flowIdentifier=0bfb3822-cbfc-4b12-8e04-07ae7cf53676
<<<<<<< HEAD
flowVersion=7
=======
flowVersion=10
>>>>>>> Update flow versions
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a
flowIdentifier=0a58beda-92c0-492e-90bd-14a6447471fd
<<<<<<< HEAD
flowVersion=8
=======
flowVersion=9
>>>>>>> Update flow versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bucketIdentifier=9a51b9f4-c902-463c-a440-4bfdac0dea6a
flowIdentifier=ded26cb5-a4a1-46f8-b2c7-c31dfad03a57
flowVersion=9
flowVersion=9
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@
"database_name": "main",
"created_by_fk": null,
"allow_ctas": false,
"sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting",
"sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g",
"changed_by_fk": null,
"allow_dml": false,
"password": "p@ssw0rd",
Expand Down Expand Up @@ -2359,7 +2359,7 @@
"database_name": "main",
"created_by_fk": null,
"allow_ctas": false,
"sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting",
"sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g",
"changed_by_fk": null,
"allow_dml": false,
"password": "p@ssw0rd",
Expand Down Expand Up @@ -3433,7 +3433,7 @@
"database_name": "main",
"created_by_fk": null,
"allow_ctas": false,
"sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting",
"sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g",
"changed_by_fk": null,
"allow_dml": false,
"password": "p@ssw0rd",
Expand Down Expand Up @@ -6677,7 +6677,7 @@
"database_name": "main",
"created_by_fk": null,
"allow_ctas": false,
"sqlalchemy_uri": "postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting",
"sqlalchemy_uri": "postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}g",
"changed_by_fk": null,
"allow_dml": false,
"password": "p@ssw0rd",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ databases:
- database_name: main
expose_in_sqllab: true
extra: "{\r\n \"metadata_params\": {},\r\n \"engine_params\": {}\r\n}\r\n"
sqlalchemy_uri: postgresql+psycopg2://postgres:XXXXXXXXXX@db:5432/open_lmis_reporting
sqlalchemy_uri: postgresql+psycopg2://${DATABASE_USERNAME}:XXXXXXXXXX@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
tables:
- columns:
- {avg: true, column_name: adjusted_consumption, sum: true, type: DOUBLE PRECISION}
Expand Down
23 changes: 23 additions & 0 deletions reporting/config/services/superset/substitute_variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import sys
import yaml
import json
from functools import reduce

variables_map = {'${DATABASE_USERNAME}': os.environ.get('DATABASE_USERNAME'),
'${DATABASE_HOST}': os.environ.get('DATABASE_HOST'),
'${DATABASE_PORT}': os.environ.get('DATABASE_PORT'),
'${DATABASE_NAME}': os.environ.get('DATABASE_NAME')}

def replace_file_variables(file):
file_data = open(file, 'r').read()

with open(file, 'w') as f:
f.write(reduce(lambda match, kv: match.replace(*kv), variables_map.items(), file_data))

def handle_datasources_dashboards(files):
for i in files:
replace_file_variables(i)

files = sys.argv[1:]
handle_datasources_dashboards(files)
10 changes: 8 additions & 2 deletions reporting/config/services/superset/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
"""
Superset config
"""
import os
from flask_appbuilder.security.manager import AUTH_OAUTH

from superset_patchup.oauth import CustomSecurityManager

SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://postgres:p@ssw0rd@db:5432/open_lmis_reporting'
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://%(username)s:%(password)s@%(host)s:%(port)s/%(database_name)s' %{
"username": os.environ.get('DATABASE_USERNAME', 'postgres'),
"password": os.environ.get('DATABASE_PASSWORD', 'p@ssw0rd'),
"host": os.environ.get('DATABASE_HOST', 'db'),
"port": os.environ.get('DATABASE_PORT', '5432'),
"database_name": os.environ.get('DATABASE_NAME', 'open_lmis_reporting')
}
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'thisISaSECRET_1234'

Expand Down
Loading