Skip to content

Commit 4312392

Browse files
authored
Merge pull request #65 from csolidum/csolidum/regional
Add config for sts_credentials_region
2 parents c24c9e1 + 03ab399 commit 4312392

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Additionally, you can use an STS assumed role as the authenticating factor and i
9292
region eu-west-1
9393
assume_role_arn arn:aws:sts::ACCOUNT:role/ROLE
9494
assume_role_session_name SESSION_ID # Defaults to fluentd if omitted
95+
sts_credentials_region us-west-2 # Defaults to region if omitted
9596
</endpoint>
9697
```
9798

lib/fluent/plugin/out_aws-elasticsearch-service.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class AwsElasticsearchServiceOutput < ElasticsearchOutput
2020
config_param :ecs_container_credentials_relative_uri, :string, :default => nil #Set with AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable value
2121
config_param :assume_role_session_name, :string, :default => "fluentd"
2222
config_param :assume_role_web_identity_token_file, :string, :default => nil
23+
config_param :sts_credentials_region, :string, :default => nil
2324
end
2425

2526
# here overrides default value of reload_connections to false because
@@ -86,17 +87,18 @@ def credentials(opts)
8687
}).credentials
8788
end
8889
else
90+
8991
if opts[:assume_role_web_identity_token_file].nil?
9092
credentials = sts_credential_provider({
9193
role_arn: opts[:assume_role_arn],
9294
role_session_name: opts[:assume_role_session_name],
93-
region: opts[:region]
95+
region: sts_credentials_region(opts)
9496
}).credentials
9597
else
9698
credentials = sts_web_identity_credential_provider({
9799
role_arn: opts[:assume_role_arn],
98100
web_identity_token_file: opts[:assume_role_web_identity_token_file],
99-
region: opts[:region]
101+
region: sts_credentials_region(opts)
100102
}).credentials
101103
end
102104
end
@@ -111,6 +113,10 @@ def calback.inspect
111113
calback
112114
end
113115

116+
def sts_credentials_region(opts)
117+
opts[:sts_credentials_region] || opts[:region]
118+
end
119+
114120
def sts_credential_provider(opts)
115121
# AssumeRoleCredentials is an auto-refreshing credential provider
116122
@sts ||= Aws::AssumeRoleCredentials.new(opts)

0 commit comments

Comments
 (0)