File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 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:
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 )
You can’t perform that action at this time.
0 commit comments