logstash-input-sqs 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 158aeb4fe9c539fec6aa37fc449f7264b3acf332ab5f293ec9477799db8674d8
4
- data.tar.gz: d74f739c840c20613f2d3ed76a7fb2dd6984febf1a48bbbe081b24c89b72449c
3
+ metadata.gz: bbca33a52d6cff51cbe851d9cba61a874804d15dc8675866936740586478751f
4
+ data.tar.gz: '08c907ba377fa84416e7ae49f161b39909fd361cc710f4ebdd51ae97bd94e852'
5
5
  SHA512:
6
- metadata.gz: 9e1138ef62e78b84569a7175542e943cb0cc8a8caed401a3495f95c48b627be4461fc9c252ddb0032d50fa42f4789dfbbf210508d8a08e80d2baf09ba5175dff
7
- data.tar.gz: 3aacc4f45c68b0226d2e863b25be47544c50e5f24346c066ec728fd3c245405af379f413bd896c80ed65e4e07b7807ae374f0e0fe5cb3dac736ce36a2ae17c12
6
+ metadata.gz: 7fd07bb9d70f3a564a878fb42ba8a17421ea5718890ce1b125958280d5d0f2ce7943b7285d7edcec778fdbe0b421e010e5783d8e3aae3617fee0a7d3a0762db7
7
+ data.tar.gz: '087aff018b51eb2f7eaa233dc730ee817719aa89d4b877fff7b0557a189fe6ca48006a3b753efcac35712d1dbf442881dfb7c33127ee6b031393b8f12f3c58c0'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.3.0
2
+ - Feature: Add `additional_settings` option to fine-grain configuration of AWS client [#61](https://github.com/logstash-plugins/logstash-input-sqs/pull/61)
3
+
1
4
  ## 3.2.0
2
5
  - Feature: Add `queue_owner_aws_account_id` parameter for cross-account queues [#60](https://github.com/logstash-plugins/logstash-input-sqs/pull/60)
3
6
 
data/docs/index.asciidoc CHANGED
@@ -85,6 +85,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
85
85
  |=======================================================================
86
86
  |Setting |Input type|Required
87
87
  | <<plugins-{type}s-{plugin}-access_key_id>> |<<string,string>>|No
88
+ | <<plugins-{type}s-{plugin}-additional_settings>> |<<hash,hash>>|No
88
89
  | <<plugins-{type}s-{plugin}-aws_credentials_file>> |<<string,string>>|No
89
90
  | <<plugins-{type}s-{plugin}-endpoint>> |<<string,string>>|No
90
91
  | <<plugins-{type}s-{plugin}-id_field>> |<<string,string>>|No
@@ -121,6 +122,28 @@ This plugin uses the AWS SDK and supports several ways to get credentials, which
121
122
  4. Environment variables `AMAZON_ACCESS_KEY_ID` and `AMAZON_SECRET_ACCESS_KEY`
122
123
  5. IAM Instance Profile (available when running inside EC2)
123
124
 
125
+ [id="plugins-{type}s-{plugin}-additional_settings"]
126
+ ===== `additional_settings`
127
+
128
+ * Value type is <<hash,hash>>
129
+ * Default value is `{}`
130
+
131
+ Key-value pairs of settings and corresponding values used to parametrize
132
+ the connection to SQS. See full list in https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/SQS/Client.html[the AWS SDK documentation]. Example:
133
+
134
+ [source,ruby]
135
+ input {
136
+ sqs {
137
+ access_key_id => "1234"
138
+ secret_access_key => "secret"
139
+ queue => "logstash-test-queue"
140
+ additional_settings => {
141
+ force_path_style => true
142
+ follow_redirects => false
143
+ }
144
+ }
145
+ }
146
+
124
147
  [id="plugins-{type}s-{plugin}-aws_credentials_file"]
125
148
  ===== `aws_credentials_file`
126
149
 
@@ -80,6 +80,8 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
80
80
 
81
81
  default :codec, "json"
82
82
 
83
+ config :additional_settings, :validate => :hash, :default => {}
84
+
83
85
  # Name of the SQS Queue name to pull messages from. Note that this is just the name of the queue, not the URL or ARN.
84
86
  config :queue, :validate => :string, :required => true
85
87
 
@@ -116,7 +118,8 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
116
118
  end
117
119
 
118
120
  def setup_queue
119
- aws_sqs_client = Aws::SQS::Client.new(aws_options_hash)
121
+ options = symbolized_settings.merge(aws_options_hash || {})
122
+ aws_sqs_client = Aws::SQS::Client.new(options)
120
123
  @poller = Aws::SQS::QueuePoller.new(queue_url(aws_sqs_client), :client => aws_sqs_client)
121
124
  rescue Aws::SQS::Errors::ServiceError, Seahorse::Client::NetworkingError => e
122
125
  @logger.error("Cannot establish connection to Amazon SQS", exception_details(e))
@@ -195,4 +198,23 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
195
198
  details
196
199
  end
197
200
 
201
+ def symbolized_settings
202
+ @symbolized_settings ||= symbolize_keys_and_cast_true_false(@additional_settings)
203
+ end
204
+
205
+ def symbolize_keys_and_cast_true_false(hash)
206
+ case hash
207
+ when Hash
208
+ symbolized = {}
209
+ hash.each { |key, value| symbolized[key.to_sym] = symbolize_keys_and_cast_true_false(value) }
210
+ symbolized
211
+ when 'true'
212
+ true
213
+ when 'false'
214
+ false
215
+ else
216
+ hash
217
+ end
218
+ end
219
+
198
220
  end # class LogStash::Inputs::SQS
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-sqs'
3
- s.version = '3.2.0'
4
- s.licenses = ['Apache License (2.0)']
3
+ s.version = '3.3.0'
4
+ s.licenses = ['Apache-2.0']
5
5
  s.summary = "Pulls events from an Amazon Web Services Simple Queue Service queue"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
7
7
  s.authors = ["Elastic"]
@@ -67,6 +67,42 @@ describe LogStash::Inputs::SQS do
67
67
  end
68
68
  end
69
69
 
70
+ describe "additional_settings" do
71
+ context "supported settings" do
72
+ let(:config) {
73
+ {
74
+ "additional_settings" => { "force_path_style" => 'true', "ssl_verify_peer" => 'false', "profile" => 'logstash' },
75
+ "queue" => queue_name
76
+ }
77
+ }
78
+
79
+ it 'should instantiate Aws::SQS clients with force_path_style set' do
80
+ expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
81
+ # mock a remote call to retrieve the queue URL
82
+ expect(mock_sqs).to receive(:get_queue_url).with({ :queue_name => queue_name }).and_return({:queue_url => queue_url })
83
+ expect(subject).to receive(:symbolized_settings) do |arg|
84
+ expect(arg).to include({:force_path_style => true, :ssl_verify_peer => false, :profile => 'logstash'})
85
+ end.and_call_original
86
+
87
+ expect { subject.register }.not_to raise_error
88
+ end
89
+ end
90
+
91
+ context "unsupported settings" do
92
+ let(:config) {
93
+ {
94
+ "additional_settings" => { "stub_responses" => 'true', "invalid_option" => "invalid" },
95
+ "queue" => queue_name
96
+ }
97
+ }
98
+
99
+ it 'must fail with ArgumentError' do
100
+ expect {subject.register}.to raise_error(ArgumentError, /invalid_option/)
101
+ end
102
+ end
103
+
104
+ end
105
+
70
106
  context "when interrupting the plugin" do
71
107
  before do
72
108
  expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-29 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -110,7 +110,7 @@ files:
110
110
  - spec/support/helpers.rb
111
111
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
112
112
  licenses:
113
- - Apache License (2.0)
113
+ - Apache-2.0
114
114
  metadata:
115
115
  logstash_plugin: 'true'
116
116
  logstash_group: input