-
Notifications
You must be signed in to change notification settings - Fork 329
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 IMDSv2 URL when fetching credentials #1464
Conversation
urlunsplit( | ||
url_replace( | ||
urlsplit(url), | ||
path="/latest/meta-data/iam/security-credentials/", | ||
), | ||
), | ||
headers=headers, |
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 seemed unnecessary so I simplified it with L507.
) | ||
role_names = res.data.decode("utf-8").split("\n") | ||
if not role_names: | ||
raise ValueError(f"no IAM roles attached to EC2 service {url}") | ||
url += "/" + role_names[0].strip("\r") | ||
url += role_names[0].strip("\r") |
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.
The role gets added at the end of the URL that was updated on L507.
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 also in the Go implementation here: https://github.com/minio/minio-go/blob/e337e77c06bbf8a65247fb018e59c1263e4d86e1/pkg/credentials/iam_aws.go#L400-L402
We just missed it in the revisions in #1437.
@balamurugana : Fixes IMDSv2 that didn't work correctly. Only found out today. |
I am closing on behalf of #1465 |
I missed 1 change in the final version of #1437 where the URL to fetch the endpoint must include
"/latest/meta-data/iam/security-credentials/"
before the role name. This adds that back.Closes #1459.