From 9719604d7985a1d5e43e3c0025aa967e2e51f012 Mon Sep 17 00:00:00 2001 From: Sameer Sharma <30409342+CaptainSame@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:26:32 +0100 Subject: [PATCH] SEC-19136 | DAR-2360 | clearly prefer boto3 session over aws profile before checking service boto creds (#145) * SEC-19136 | prefer boto3 session over aws profile and then service boto creds * SEC-19136 | bump up version --------- Co-authored-by: Sameer Sharma --- service_configuration_lib/spark_config.py | 11 ++++++++--- setup.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/service_configuration_lib/spark_config.py b/service_configuration_lib/spark_config.py index 72f74d4..db39de0 100644 --- a/service_configuration_lib/spark_config.py +++ b/service_configuration_lib/spark_config.py @@ -148,8 +148,13 @@ def get_aws_credentials( session['Credentials']['SecretAccessKey'], session['Credentials']['SessionToken'], ) + # use the boto3 session if provided + elif session: + return use_aws_profile(session=session) + # use the aws profile if provided elif profile_name: - return use_aws_profile(profile_name=profile_name, session=session) + return use_aws_profile(profile_name=profile_name) + # use the service specific boto creds if boto3 session or aws profile is not provided elif service != DEFAULT_SPARK_SERVICE: service_credentials_path = os.path.join(AWS_CREDENTIALS_DIR, f'{service}.yaml') if os.path.exists(service_credentials_path): @@ -159,8 +164,8 @@ def get_aws_credentials( f'Did not find service AWS credentials at {service_credentials_path}. ' 'Falling back to user credentials.', ) - - return use_aws_profile(session=session) + # try to get default aws profile creds if nothing else is provided + return use_aws_profile() def use_aws_profile( diff --git a/setup.py b/setup.py index fd85e24..a3cb438 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( name='service-configuration-lib', - version='2.18.18', + version='2.18.19', provides=['service_configuration_lib'], description='Start, stop, and inspect Yelp SOA services', url='https://github.com/Yelp/service_configuration_lib',