Skip to content

Commit 169fe81

Browse files
authored
IamAwsProvider: fix url with role name (#1465)
Signed-off-by: Bala.FA <[email protected]>
1 parent 94c60c5 commit 169fe81

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

minio/credentials/providers.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -505,21 +505,17 @@ def retrieve(self) -> Credentials:
505505
headers = {"X-aws-ec2-metadata-token": token} if token else None
506506

507507
# Get role name
508-
res = _urlopen(
509-
self._http_client,
510-
"GET",
511-
urlunsplit(
512-
url_replace(
513-
urlsplit(url),
514-
path="/latest/meta-data/iam/security-credentials/",
515-
),
508+
url = urlunsplit(
509+
url_replace(
510+
urlsplit(url),
511+
path="/latest/meta-data/iam/security-credentials/",
516512
),
517-
headers=headers,
518513
)
514+
res = _urlopen(self._http_client, "GET", url, headers=headers)
519515
role_names = res.data.decode("utf-8").split("\n")
520516
if not role_names:
521517
raise ValueError(f"no IAM roles attached to EC2 service {url}")
522-
url += "/" + role_names[0].strip("\r")
518+
url += role_names[0].strip("\r")
523519
if not url:
524520
raise ValueError("url is empty; this should not happen")
525521
self._credentials = self.fetch(url, headers=headers)

0 commit comments

Comments
 (0)