mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-16 21:37:59 +08:00
* Enhance the AppConfig with external config sources. The external config sources are currently environment variables and AWS secrets manager. The config file can be augmented with a section describing how environmen variables and secrets can update config parameters. benefits: - it will enable the config to draw from more than one secret. This is useful for shared secrets between cellxgene and data portal, as well as auth0 secrets. - it will make it very straightforward to check the config before a deployment. Part of #1859
24 lines
729 B
Python
24 lines
729 B
Python
import logging
|
|
|
|
import boto3
|
|
from flask import json
|
|
|
|
from server.common.errors import SecretKeyRetrievalError
|
|
|
|
|
|
def get_secret_key(region_name, secret_name):
|
|
session = boto3.session.Session()
|
|
client = session.client(service_name="secretsmanager", region_name=region_name)
|
|
|
|
try:
|
|
get_secret_value_response = client.get_secret_value(SecretId=secret_name)
|
|
if "SecretString" in get_secret_value_response:
|
|
var = get_secret_value_response["SecretString"]
|
|
secret = json.loads(var)
|
|
return secret
|
|
except Exception as e:
|
|
logging.critical(f"Caught exception during get_secret_key, {e}", exc_info=True)
|
|
raise SecretKeyRetrievalError(str(e))
|
|
|
|
return None
|