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
Refactor aws_stack.mock_aws_request_headers() #9509
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
viren-nadkarni
added
the
semver: patch
Non-breaking changes which can be included in patch releases
label
Oct 30, 2023
viren-nadkarni
commented
Oct 30, 2023
Comment on lines
146
to
151
auth_header = ( | ||
auth_header | ||
or aws_stack.generate_aws_request_headers( | ||
service_name, aws_access_key_id=DEFAULT_AWS_ACCOUNT_ID, region_name=AWS_REGION_US_EAST_1 | ||
)["Authorization"] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dead code but updated anyway
viren-nadkarni
changed the title
Refactor aws_stack.mock_aws_request_headers
Refactor aws_stack.mock_aws_request_headers()
Oct 30, 2023
This reverts commit c838cfc.
viren-nadkarni
force-pushed
the
refactor-mock-aws-headers-helper
branch
from
October 31, 2023 06:10
7c80475
to
351458d
Compare
viren-nadkarni
requested review from
thrau,
baermat,
dominikschubert,
MEPalma,
bentsku,
macnev2013,
joe4dev,
dfangl,
giograno,
steffyP,
silv-io,
pinzon and
simonrw
as code owners
November 1, 2023 05:19
viren-nadkarni
requested review from
alexrashed
and removed request for
simonrw,
dominikschubert,
calvernaz,
thrau,
steffyP,
giograno,
joe4dev,
silv-io,
macnev2013,
dfangl,
pinzon,
MEPalma and
baermat
November 1, 2023 05:20
alexrashed
approved these changes
Nov 1, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for churning over all these refactorings to properly use the account ID and regions everywhere! 🧹 🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The
aws_stack.mock_aws_request_headers()
utility is used in our codebase to generate headers for AWS requests. Among these headers includeContent-Type
,Accept-Encoding
, date and especially theAuthorization
header.The issue this PR is addressing is the optional nature of the access key and region name arguments for this function, in which the
get_aws_access_key_id()
andaws_stack.get_region()
are used. We already know that these are problematic functions that rely on thread context storage and are not guaranteed to return the correct values. Furthermore they must not be used in tests, indirectly which is exactly what is happening.Implementation
This PR makes the access key ID and region name field mandatory.