Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|=======================================================================
|Setting |Input type|Required
| <<plugins-{type}s-{plugin}-access_key_id>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-additional_settings>> |<<hash,hash>>|No
| <<plugins-{type}s-{plugin}-aws_credentials_file>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-backup_add_prefix>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-backup_to_bucket>> |<<string,string>>|No
Expand Down Expand Up @@ -139,6 +140,28 @@ Whether to delete processed files from the original bucket.

Ruby style regexp of keys to exclude from the bucket

[id="plugins-{type}s-{plugin}-additional_settings"]
===== `additional_settings`

* Value type is <<hash,hash>>
* Default value is `{}`

Key-value pairs of settings and corresponding values used to parametrize
the connection to s3. See full list in https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html[the AWS SDK documentation]. Example:

[source,ruby]
input {
s3 {
"access_key_id" => "1234",
"secret_access_key" => "secret",
"bucket" => "logstash-test",
"additional_settings" => {
"force_path_style => true,
"follow_redirects" => false
}
}
}

[id="plugins-{type}s-{plugin}-interval"]
===== `interval`

Expand Down
5 changes: 4 additions & 1 deletion lib/logstash/inputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
# If specified, the prefix of filenames in the bucket must match (not a regexp)
config :prefix, :validate => :string, :default => nil

config :additional_settings, :validate => :hash, :default => {}

# The path to use for writing state. The state stored by this plugin is
# a memory of files already processed by this plugin.
#
Expand Down Expand Up @@ -386,7 +388,8 @@ def delete_file_from_bucket(object)

private
def get_s3object
s3 = Aws::S3::Resource.new(aws_options_hash)
options = @additional_settings.merge(aws_options_hash || {})
s3 = Aws::S3::Resource.new(options)
end

private
Expand Down
33 changes: 33 additions & 0 deletions spec/inputs/s3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@
subject.send(:get_s3object)
end
end

describe "additional_settings" do
context 'when force_path_style is set' do
let(:settings) {
{
"additional_settings" => { "force_path_style" => true },
"bucket" => "logstash-test",
}
}

it 'should instantiate AWS::S3 clients with force_path_style set' do
expect(Aws::S3::Resource).to receive(:new).with({
:region => subject.region,
"force_path_style" => true
}).and_call_original

subject.send(:get_s3object)
end
end

context 'when an unknown setting is given' do
let(:settings) {
{
"additional_settings" => { "this_setting_doesnt_exist" => true },
"bucket" => "logstash-test",
}
}

it 'should raise an error' do
expect { subject.send(:get_s3object) }.to raise_error(ArgumentError)
end
end
end
end

describe "#list_new_files" do
Expand Down