Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Credentials Refresh when Not Assuming Roles #335

Merged
merged 3 commits into from
Jul 17, 2024
Merged

Conversation

zprobst
Copy link
Contributor

@zprobst zprobst commented Jul 17, 2024

By default, if we do not assume a role, we grab a basic boto score session which gets the credentials without refreshing. This PR introduces a change to fall back on a regular boto3 session which will fetch again from the provider chain.

@zprobst zprobst requested a review from ccloes as a code owner July 17, 2024 17:04
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.87%. Comparing base (7882c36) to head (4365a0d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #335   +/-   ##
=======================================
  Coverage   97.87%   97.87%           
=======================================
  Files         144      144           
  Lines        5136     5141    +5     
=======================================
+ Hits         5027     5032    +5     
  Misses        109      109           
Flag Coverage Δ
3.10-macos-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.10-ubuntu-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.10-windows-latest 97.83% <100.00%> (+<0.01%) ⬆️
3.11-macos-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.11-ubuntu-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.11-windows-latest 97.83% <100.00%> (+<0.01%) ⬆️
3.12-macos-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.12-ubuntu-latest 97.87% <100.00%> (+<0.01%) ⬆️
3.12-windows-latest 97.83% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return boto3.Session(botocore_session=session, **self.session_args).client(
client_name
)
return boto3.client(client_name, **self.session_args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this base client will refresh credentials using the user's arn by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Turns out It will in some cases... but not all: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html

I've updated it.

@zprobst zprobst merged commit 2474f4d into main Jul 17, 2024
11 checks passed
@zprobst zprobst deleted the fix/aws-credentials branch July 17, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants