@@ -123,6 +123,7 @@ class Config(object):
123123 _access_token_last_update = None
124124 host_base = u"s3.amazonaws.com"
125125 host_bucket = u"%(bucket)s.s3.amazonaws.com"
126+ sts_endpoint = u"sts.amazonaws.com"
126127 kms_key = u"" #can't set this and Server Side Encryption at the same time
127128 # simpledb_host looks useless, legacy? to remove?
128129 simpledb_host = u"sdb.amazonaws.com"
@@ -314,6 +315,7 @@ def role_config(self):
314315 Get credentials from IAM authentication and STS AssumeRole
315316 """
316317 try :
318+ sts_endpoint = self .sts_endpoint
317319 role_arn = os .environ .get ('AWS_ROLE_ARN' )
318320 if role_arn :
319321 role_session_name = 'role-session-%s' % (int (time .time ()))
@@ -326,14 +328,14 @@ def role_config(self):
326328 web_identity_token_file = os .environ .get ('AWS_WEB_IDENTITY_TOKEN_FILE' )
327329 if web_identity_token_file :
328330 with open (web_identity_token_file ) as f :
329- web_identity_token = f .read ()
331+ web_identity_token = f .read (). rstrip ()
330332 params ['Action' ] = 'AssumeRoleWithWebIdentity'
331333 params ['WebIdentityToken' ] = web_identity_token
332334 encoded_params = '&' .join ([
333335 '%s=%s' % (k , s3_quote (v , unicode_output = True ))
334336 for k , v in params .items ()
335337 ])
336- sts_endpoint = "sts.amazonaws.com"
338+ sts_endpoint = os . environ . get ( "AWS_STS_ENDPOINT" , sts_endpoint )
337339 if os .environ .get ("AWS_STS_REGIONAL_ENDPOINTS" ) == "regional" :
338340 # Check if the AWS_REGION variable is available to use as a region.
339341 region = os .environ .get ("AWS_REGION" )
0 commit comments