Skip to content

Commit

Permalink
C4-90 Update utils for new production envs (#62)
Browse files Browse the repository at this point in the history
* some small compatibility fixes for new production envs

* C4-90 small changes per Kents suggestions
  • Loading branch information
willronchetti authored Mar 24, 2020
1 parent ef4ab2a commit b854df5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 8 additions & 4 deletions dcicutils/beanstalk_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

FOURSIGHT_URL = 'https://foursight.4dnucleome.org/'
# magic CNAME corresponds to data.4dnucleome
MAGIC_CNAME = 'fourfront-webprod.9wzadzju3p.us-east-1.elasticbeanstalk.com'
GOLDEN_DB = "fourfront-webprod.co3gwj7b7tpq.us-east-1.rds.amazonaws.com"
MAGIC_CNAME = 'fourfront-green.us-east-1.elasticbeanstalk.com'
GOLDEN_DB = 'fourfront-production.co3gwj7b7tpq.us-east-1.rds.amazonaws.com'
REGION = 'us-east-1'


Expand All @@ -48,7 +48,7 @@ def delete_db(db_identifier, take_snapshot=True, allow_delete_prod=False):
dict: boto3 response from delete_db_instance
"""
# safety. Do not allow accidental programmatic deletion of webprod DB
if 'webprod' in db_identifier and not allow_delete_prod:
if 'prod' in db_identifier and not allow_delete_prod:
raise Exception('Must set allow_delete_prod to True to delete RDS instance' % db_identifier)
client = boto3.client('rds')
timestamp = datetime.strftime(datetime.utcnow(), "%Y-%m-%d")
Expand Down Expand Up @@ -246,7 +246,9 @@ def get_beanstalk_real_url(env):
if env in urls:
return urls[env]

if 'webprod' in env:
# TODO (C4-91): Reconsider environment names.
# This code is too fragile.
if 'webprod' in env or 'blue' in env or 'green' in env:
data_env = whodaman()

if data_env == env:
Expand Down Expand Up @@ -590,6 +592,8 @@ def update_bs_config(envname, template=None, keep_env_vars=False,

def create_bs(envname, load_prod, db_endpoint, es_url, for_indexing=False):
"""
XXX: Will not work currently, do NOT use on production
Create a beanstalk environment given an envname. Use customized options,
configuration template, and environment variables. If adding new env vars,
make sure to overwrite them here.
Expand Down
11 changes: 9 additions & 2 deletions dcicutils/ff_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
'elasticbeanstalk-fourfront-webdev-wfoutput']


# TODO (C4-92): Centralize this information, it is repeated in other repos
PRODUCTION_ENVS = ['fourfront-blue', 'fourfront-green']


##################################
# Widely used metadata functions #
##################################
Expand Down Expand Up @@ -1062,8 +1066,11 @@ def unified_authentication(auth=None, ff_env=None):
"""
# first see if key should be obtained from using ff_env
if not auth and ff_env:
# webprod and webprod2 both use the fourfront-webprod bucket for keys
use_env = 'fourfront-webprod' if 'webprod' in ff_env else ff_env
# webprod, webprod2 and blue/green all use the fourfront-webprod bucket for keys
if 'webprod' in ff_env or ff_env in PRODUCTION_ENVS:
use_env = 'fourfront-webprod'
else:
use_env = ff_env
auth = s3_utils.s3Utils(env=use_env).get_access_keys()
# see if auth is directly from get_access_keys()
use_auth = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "0.9.5"
version = "0.9.6"
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["William Ronchetti <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit b854df5

Please sign in to comment.