@@ -123,6 +123,7 @@ class Config(object):
123
123
_access_token_last_update = None
124
124
host_base = u"s3.amazonaws.com"
125
125
host_bucket = u"%(bucket)s.s3.amazonaws.com"
126
+ sts_endpoint = u"sts.amazonaws.com"
126
127
kms_key = u"" #can't set this and Server Side Encryption at the same time
127
128
# simpledb_host looks useless, legacy? to remove?
128
129
simpledb_host = u"sdb.amazonaws.com"
@@ -314,6 +315,7 @@ def role_config(self):
314
315
Get credentials from IAM authentication and STS AssumeRole
315
316
"""
316
317
try :
318
+ sts_endpoint = self .sts_endpoint
317
319
role_arn = os .environ .get ('AWS_ROLE_ARN' )
318
320
if role_arn :
319
321
role_session_name = 'role-session-%s' % (int (time .time ()))
@@ -326,14 +328,14 @@ def role_config(self):
326
328
web_identity_token_file = os .environ .get ('AWS_WEB_IDENTITY_TOKEN_FILE' )
327
329
if web_identity_token_file :
328
330
with open (web_identity_token_file ) as f :
329
- web_identity_token = f .read ()
331
+ web_identity_token = f .read (). rstrip ()
330
332
params ['Action' ] = 'AssumeRoleWithWebIdentity'
331
333
params ['WebIdentityToken' ] = web_identity_token
332
334
encoded_params = '&' .join ([
333
335
'%s=%s' % (k , s3_quote (v , unicode_output = True ))
334
336
for k , v in params .items ()
335
337
])
336
- sts_endpoint = "sts.amazonaws.com"
338
+ sts_endpoint = os . environ . get ( "AWS_STS_ENDPOINT" , sts_endpoint )
337
339
if os .environ .get ("AWS_STS_REGIONAL_ENDPOINTS" ) == "regional" :
338
340
# Check if the AWS_REGION variable is available to use as a region.
339
341
region = os .environ .get ("AWS_REGION" )
0 commit comments