Skip to content

Commit

Permalink
SEC-19136 | DAR-2360 | clearly prefer boto3 session over aws profile …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
CaptainSame and Sameer Sharma authored Jul 4, 2024
1 parent b97f586 commit 9719604
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions service_configuration_lib/spark_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9719604

Please sign in to comment.