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

fix: Add AWS session token to metadata requests #958

Merged
merged 7 commits into from
Feb 5, 2022
Merged

fix: Add AWS session token to metadata requests #958

merged 7 commits into from
Feb 5, 2022

Conversation

sai-sunder-s
Copy link
Contributor

AWS instance metadata service v2 introduced a need for session token when making call to the meta data endpoints. This change add the code to fetch the session token and add to our requests to metadata urls.

@sai-sunder-s sai-sunder-s changed the title Add AWS session token to metadata requests fix: Add AWS session token to metadata requests Jan 25, 2022
@arithmetic1728 arithmetic1728 marked this pull request as ready for review February 3, 2022 23:28
@arithmetic1728 arithmetic1728 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 3, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 3, 2022
Comment on lines +566 to +568
headers = None
if session_token is not None:
headers = {"X-aws-ec2-metadata-token": session_token}
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be done in one line:

Suggested change
headers = None
if session_token is not None:
headers = {"X-aws-ec2-metadata-token": session_token}
headers = {"X-aws-ec2-metadata-token": session_token} if session_token else None

Comment on lines +707 to +709
headers = None
if session_token is not None:
headers = {"X-aws-ec2-metadata-token": session_token}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
headers = None
if session_token is not None:
headers = {"X-aws-ec2-metadata-token": session_token}
headers = {"X-aws-ec2-metadata-token": session_token} if session_token else None

@lsirac
Copy link
Contributor

lsirac commented Feb 7, 2022

Hey Sai, can you please update the README too? I think it'll be important to document this

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.

4 participants