1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Only use STS regional endpoint if a region is specified

This commit is contained in:
Stan Hu 2021-08-20 11:25:21 -07:00
parent dad90af22d
commit 1eccc9627c
No known key found for this signature in database
GPG key ID: 8D3931AD39CC7A20
2 changed files with 12 additions and 1 deletions

View file

@ -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"

View file

@ -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',