Skip to content

Commit a1f51b9

Browse files
committed
Add support for InstanceProfileCredentials to in_s3
use InstanceProfileCredentials instead of ECSCredentials if AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set Signed-off-by: Joshua Atkins <[email protected]>
1 parent 1c9c7c8 commit a1f51b9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/fluent/plugin/in_s3.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,20 @@ def setup_credentials
209209
credentials_options[:port] = c.port if c.port
210210
credentials_options[:http_open_timeout] = c.http_open_timeout if c.http_open_timeout
211211
credentials_options[:http_read_timeout] = c.http_read_timeout if c.http_read_timeout
212-
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)
212+
if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
213+
options[:credentials] = Aws::ECSCredentials.new(credentials_options)
214+
else
215+
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)
216+
end
213217
when @shared_credentials
214218
c = @shared_credentials
215219
credentials_options[:path] = c.path if c.path
216220
credentials_options[:profile_name] = c.profile_name if c.profile_name
217-
options[:credentials] = Aws::SharedCredentials.new(credentials_options)
221+
if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
222+
options[:credentials] = Aws::ECSCredentials.new(credentials_options)
223+
else
224+
options[:credentials] = Aws::InstanceProfileCredentials.new(credentials_options)
225+
end
218226
else
219227
# Use default credentials
220228
# See http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html

0 commit comments

Comments
 (0)