sts seems to require the region where Lemur is deployed

This commit is contained in:
Hossein Shafagh 2021-03-03 14:24:22 -08:00
parent 576122393b
commit a49570e5f9
1 changed files with 7 additions and 1 deletions

View File

@ -20,7 +20,13 @@ def sts_client(service, service_type="client"):
def decorator(f): def decorator(f):
@wraps(f) @wraps(f)
def decorated_function(*args, **kwargs): def decorated_function(*args, **kwargs):
sts = boto3.client("sts", config=config) if current_app.config.get("LEMUR_AWS_REGION"):
deployment_region = current_app.config.get("LEMUR_AWS_REGION")
sts = boto3.client('sts', region_name=deployment_region,
endpoint_url=f"https://sts.{deployment_region}.amazonaws.com/",
config=config)
else:
sts = boto3.client("sts", config=config)
arn = "arn:aws:iam::{0}:role/{1}".format( arn = "arn:aws:iam::{0}:role/{1}".format(
kwargs.pop("account_number"), kwargs.pop("account_number"),
current_app.config.get("LEMUR_INSTANCE_PROFILE", "Lemur"), current_app.config.get("LEMUR_INSTANCE_PROFILE", "Lemur"),