diff --git a/lib/fog/aws/credential_fetcher.rb b/lib/fog/aws/credential_fetcher.rb index 0ce411419..7699b865d 100644 --- a/lib/fog/aws/credential_fetcher.rb +++ b/lib/fog/aws/credential_fetcher.rb @@ -44,7 +44,7 @@ module Fog } sts_endpoint = - if ENV["AWS_STS_REGIONAL_ENDPOINTS"] == "regional" + if ENV["AWS_STS_REGIONAL_ENDPOINTS"] == "regional" && region "https://sts.#{region}.amazonaws.com" else "https://sts.amazonaws.com" diff --git a/tests/credentials_tests.rb b/tests/credentials_tests.rb index e3981769e..36f031e52 100644 --- a/tests/credentials_tests.rb +++ b/tests/credentials_tests.rb @@ -103,6 +103,17 @@ Shindo.tests('AWS | credentials', ['aws']) do ENV["AWS_STS_REGIONAL_ENDPOINTS"] = "regional" + tests('#fetch_credentials with no region specified') do + returns( + aws_access_key_id: 'dummykey', + aws_secret_access_key: 'dummysecret', + aws_session_token: 'dummytoken', + region: 'us-west-1', + sts_endpoint: "https://sts.amazonaws.com", + aws_credentials_expire_at: expires_at + ) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) } + end + tests('#fetch_credentials with regional STS endpoint') do returns( aws_access_key_id: 'dummykey',