Skip to content

Commit

Permalink
Fixes #1259 - Correct typo when retrieving response from IMDSv2
Browse files Browse the repository at this point in the history
Typo introduced by d87d816
  • Loading branch information
fviard committed Jul 6, 2022
1 parent d87d816 commit e4d248a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions S3/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ def role_config(self):
for k, v in params.items()
])
sts_endpoint = "sts.amazonaws.com"
if os.environ.get("AWS_STS_REGIONAL_ENDPOINTS") == "regional":
# Check if the AWS_REGION variable is available to use as a region.
if os.environ.get("AWS_STS_REGIONAL_ENDPOINTS") == "regional":
# Check if the AWS_REGION variable is available to use as a region.
region = os.environ.get("AWS_REGION")
if not region:
if not region:
# Otherwise use the bucket location
region = self.bucket_location
sts_endpoint = "sts.%s.amazonaws.com" % region
sts_endpoint = "sts.%s.amazonaws.com" % region
conn = httplib.HTTPSConnection(host=sts_endpoint,
timeout=2)
conn.request('POST', '/?' + encoded_params)
Expand Down Expand Up @@ -374,7 +374,7 @@ def role_config(self):
imds_ttl = {"X-aws-ec2-metadata-token-ttl-seconds": "60"}
conn.request('PUT', "/latest/api/token", headers=imds_ttl)
resp = conn.getresponse()
resp_content = conn.read()
resp_content = resp.read()
if resp.status == 200:
imds_token = base_unicodise(resp_content)
imds_auth = {"X-aws-ec2-metadata-token": imds_token}
Expand All @@ -391,7 +391,7 @@ def role_config(self):
resp=conn.getresponse()
if resp.status == 200:
resp_content = base_unicodise(resp.read())
creds=json.loads(resp_content)
creds = json.loads(resp_content)
Config().update_option('access_key', base_unicodise(creds['AccessKeyId']))
Config().update_option('secret_key', base_unicodise(creds['SecretAccessKey']))
Config().update_option('access_token', base_unicodise(creds['Token']))
Expand Down

0 comments on commit e4d248a

Please sign in to comment.