mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Added AWS files to
- upgrade database - use credstash for secret overrides
This commit is contained in:
@@ -15,7 +15,7 @@ ma = Marshmallow()
|
|||||||
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
|
api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user)
|
||||||
|
|
||||||
|
|
||||||
def create_app(config_name):
|
def create_app(config_name, config_overrides=None):
|
||||||
application = Flask(__name__)
|
application = Flask(__name__)
|
||||||
|
|
||||||
application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
||||||
@@ -23,7 +23,7 @@ def create_app(config_name):
|
|||||||
|
|
||||||
db.init_app(application)
|
db.init_app(application)
|
||||||
ma.init_app(application)
|
ma.init_app(application)
|
||||||
init_app(application)
|
init_app(application, config_overrides)
|
||||||
logging.init_app(application)
|
logging.init_app(application)
|
||||||
|
|
||||||
from app.service.rest import service as service_blueprint
|
from app.service.rest import service as service_blueprint
|
||||||
@@ -41,11 +41,16 @@ def create_app(config_name):
|
|||||||
return application
|
return application
|
||||||
|
|
||||||
|
|
||||||
def init_app(app):
|
def init_app(app, config_overrides):
|
||||||
for key, value in app.config.items():
|
for key, value in app.config.items():
|
||||||
if key in os.environ:
|
if key in os.environ:
|
||||||
app.config[key] = convert_to_boolean(os.environ[key])
|
app.config[key] = convert_to_boolean(os.environ[key])
|
||||||
|
|
||||||
|
if config_overrides:
|
||||||
|
for key in app.config.keys():
|
||||||
|
if key in config_overrides:
|
||||||
|
app.config[key] = config_overrides[key]
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def required_authentication():
|
def required_authentication():
|
||||||
from app.authentication import auth
|
from app.authentication import auth
|
||||||
|
|||||||
15
db.py
Normal file
15
db.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from flask.ext.script import Manager, Server
|
||||||
|
from flask_migrate import Migrate, MigrateCommand
|
||||||
|
from app import create_app, db
|
||||||
|
from credstash import getAllSecrets
|
||||||
|
|
||||||
|
secrets = getAllSecrets(region="eu-west-1")
|
||||||
|
|
||||||
|
application = create_app('live', secrets)
|
||||||
|
|
||||||
|
manager = Manager(application)
|
||||||
|
migrate = Migrate(application, db)
|
||||||
|
manager.add_command('db', MigrateCommand)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
manager.run()
|
||||||
@@ -11,6 +11,7 @@ marshmallow-sqlalchemy==0.8.0
|
|||||||
flask-marshmallow==0.6.2
|
flask-marshmallow==0.6.2
|
||||||
itsdangerous==0.24
|
itsdangerous==0.24
|
||||||
Flask-Bcrypt==0.6.2
|
Flask-Bcrypt==0.6.2
|
||||||
|
credstash==1.8.0
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-python-client.git@0.1.5#egg=notifications-python-client==0.1.5
|
git+https://github.com/alphagov/notifications-python-client.git@0.1.5#egg=notifications-python-client==0.1.5
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
|
echo "Install dependencies"
|
||||||
|
cd /home/ubuntu/notifications-api;
|
||||||
pip3 install -r /home/ubuntu/notifications-api/requirements.txt
|
pip3 install -r /home/ubuntu/notifications-api/requirements.txt
|
||||||
|
python3 db.py db upgrade
|
||||||
|
|||||||
5
wsgi.py
5
wsgi.py
@@ -1,6 +1,9 @@
|
|||||||
from app import create_app
|
from app import create_app
|
||||||
|
from credstash import getAllSecrets
|
||||||
|
|
||||||
application = create_app('live')
|
secrets = getAllSecrets(region="eu-west-1")
|
||||||
|
|
||||||
|
application = create_app('live', secrets)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
application.run()
|
application.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user