Skip to content

Commit 05e4ff2

Browse files
authored
Support AWS_ENDPOINT_URL_STS environment variable (#724)
As described in https://docs.aws.amazon.com/sdkref/latest/guide/ss-endpoints-table.html, the STS endpoint can be configured with the AWS_ENDPOINT_URL_STS environment variable. This might be necessary for users of Amazon Secret Cloud (https://aws.amazon.com/federal/secret-cloud/), for example.
1 parent 5315d46 commit 05e4ff2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/fog/aws/credential_fetcher.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def fetch_credentials(options)
5656
}
5757

5858
sts_endpoint =
59-
if ENV["AWS_STS_REGIONAL_ENDPOINTS"] == "regional" && region
59+
if ENV["AWS_ENDPOINT_URL_STS"]
60+
ENV["AWS_ENDPOINT_URL_STS"]
61+
elsif ENV["AWS_STS_REGIONAL_ENDPOINTS"] == "regional" && region
6062
"https://sts.#{region}.amazonaws.com"
6163
else
6264
"https://sts.amazonaws.com"

tests/credentials_tests.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@
202202
) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
203203
end
204204

205+
ENV["AWS_ENDPOINT_URL_STS"] = "https://my-special-sts.amazonaws.com"
206+
207+
tests('#fetch_credentials with global STS endpoint set in env') do
208+
returns(
209+
aws_access_key_id: 'dummykey',
210+
aws_secret_access_key: 'dummysecret',
211+
aws_session_token: 'dummytoken',
212+
region: 'us-west-1',
213+
sts_endpoint: "https://my-special-sts.amazonaws.com",
214+
aws_credentials_expire_at: expires_at
215+
) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
216+
end
217+
218+
ENV["AWS_ENDPOINT_URL_STS"] = nil
205219
ENV["AWS_STS_REGIONAL_ENDPOINTS"] = nil
206220
ENV["AWS_DEFAULT_REGION"] = nil
207221
ENV["AWS_REGION"] = nil

0 commit comments

Comments
 (0)