File tree 1 file changed +6
-10
lines changed
1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -505,21 +505,17 @@ def retrieve(self) -> Credentials:
505
505
headers = {"X-aws-ec2-metadata-token" : token } if token else None
506
506
507
507
# 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/" ,
516
512
),
517
- headers = headers ,
518
513
)
514
+ res = _urlopen (self ._http_client , "GET" , url , headers = headers )
519
515
role_names = res .data .decode ("utf-8" ).split ("\n " )
520
516
if not role_names :
521
517
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 " )
523
519
if not url :
524
520
raise ValueError ("url is empty; this should not happen" )
525
521
self ._credentials = self .fetch (url , headers = headers )
You can’t perform that action at this time.
0 commit comments