@@ -39,6 +39,8 @@ def initialize
39
39
config_param :duration_seconds , :integer , default : nil
40
40
desc "A unique identifier that is used by third parties when assuming roles in their customers' accounts."
41
41
config_param :external_id , :string , default : nil , secret : true
42
+ desc "The region of the STS endpoint to use."
43
+ config_param :sts_region , :string , default : nil
42
44
end
43
45
# See the following link for additional params that could be added:
44
46
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/STS/Client.html#assume_role_with_web_identity-instance_method
@@ -53,6 +55,8 @@ def initialize
53
55
config_param :policy , :string , default : nil
54
56
desc "The duration, in seconds, of the role session (900-43200)"
55
57
config_param :duration_seconds , :integer , default : nil
58
+ desc "The region of the STS endpoint to use."
59
+ config_param :sts_region , :string , default : nil
56
60
end
57
61
config_section :instance_profile_credentials , multi : false do
58
62
desc "Number of times to retry when retrieving credentials"
@@ -470,7 +474,9 @@ def setup_credentials
470
474
credentials_options [ :policy ] = c . policy if c . policy
471
475
credentials_options [ :duration_seconds ] = c . duration_seconds if c . duration_seconds
472
476
credentials_options [ :external_id ] = c . external_id if c . external_id
473
- if @s3_region
477
+ if c . sts_region
478
+ credentials_options [ :client ] = Aws ::STS ::Client . new ( region : c . sts_region )
479
+ elsif @s3_region
474
480
credentials_options [ :client ] = Aws ::STS ::Client . new ( region : @s3_region )
475
481
end
476
482
options [ :credentials ] = Aws ::AssumeRoleCredentials . new ( credentials_options )
@@ -481,7 +487,9 @@ def setup_credentials
481
487
credentials_options [ :web_identity_token_file ] = c . web_identity_token_file
482
488
credentials_options [ :policy ] = c . policy if c . policy
483
489
credentials_options [ :duration_seconds ] = c . duration_seconds if c . duration_seconds
484
- if @s3_region
490
+ if c . sts_region
491
+ credentials_options [ :client ] = Aws ::STS ::Client . new ( :region => c . sts_region )
492
+ elsif @s3_region
485
493
credentials_options [ :client ] = Aws ::STS ::Client . new ( :region => @s3_region )
486
494
end
487
495
options [ :credentials ] = Aws ::AssumeRoleWebIdentityCredentials . new ( credentials_options )
0 commit comments