logstash-input-sqs 3.1.3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62052e70008ae3f83113fdd4d78bbd83624d357e5efb9ce4767bd724c8442cf2
4
- data.tar.gz: b04b422569e0105cf038972e235c15280acc6bdca4be8303b05aad56256a6659
3
+ metadata.gz: 158aeb4fe9c539fec6aa37fc449f7264b3acf332ab5f293ec9477799db8674d8
4
+ data.tar.gz: d74f739c840c20613f2d3ed76a7fb2dd6984febf1a48bbbe081b24c89b72449c
5
5
  SHA512:
6
- metadata.gz: 36f7bae7b415c1fe4b475ffea461a23e8e431d16c082f1c19491c6640a2bc0fdb73e1f1eb230d025b5a8ac2d60cc55bc37cc28ae22055bd92d7e921260c3eff0
7
- data.tar.gz: 98987e8fa698be674e48b02456f25e72422c78b2148748f0e924e05953c095c59074188e5f17bc124a3b18b7d291f1e2a6f906c24895f96d24fb9b3ecda190ad
6
+ metadata.gz: 9e1138ef62e78b84569a7175542e943cb0cc8a8caed401a3495f95c48b627be4461fc9c252ddb0032d50fa42f4789dfbbf210508d8a08e80d2baf09ba5175dff
7
+ data.tar.gz: 3aacc4f45c68b0226d2e863b25be47544c50e5f24346c066ec728fd3c245405af379f413bd896c80ed65e4e07b7807ae374f0e0fe5cb3dac736ce36a2ae17c12
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.2.0
2
+ - Feature: Add `queue_owner_aws_account_id` parameter for cross-account queues [#60](https://github.com/logstash-plugins/logstash-input-sqs/pull/60)
3
+
1
4
  ## 3.1.3
2
5
  - Fix: retry networking errors (with backoff) [#57](https://github.com/logstash-plugins/logstash-input-sqs/pull/57)
3
6
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-input-sqs.svg)](https://travis-ci.org/logstash-plugins/logstash-input-sqs)
3
+ [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-input-sqs.svg)](https://travis-ci.com/logstash-plugins/logstash-input-sqs)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
data/docs/index.asciidoc CHANGED
@@ -92,6 +92,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
92
92
  | <<plugins-{type}s-{plugin}-polling_frequency>> |<<number,number>>|No
93
93
  | <<plugins-{type}s-{plugin}-proxy_uri>> |<<string,string>>|No
94
94
  | <<plugins-{type}s-{plugin}-queue>> |<<string,string>>|Yes
95
+ | <<plugins-{type}s-{plugin}-queue_owner_aws_account_id>> |<<string,string>>|No
95
96
  | <<plugins-{type}s-{plugin}-region>> |<<string,string>>|No
96
97
  | <<plugins-{type}s-{plugin}-role_arn>> |<<string,string>>|No
97
98
  | <<plugins-{type}s-{plugin}-role_session_name>> |<<string,string>>|No
@@ -188,6 +189,14 @@ URI to proxy server if required
188
189
 
189
190
  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.
190
191
 
192
+ [id="plugins-{type}s-{plugin}-queue_owner_aws_account_id"]
193
+ ===== `queue_owner_aws_account_id`
194
+
195
+ * Value type is <<string,string>>
196
+ * There is no default value for this setting.
197
+
198
+ ID of the AWS account owning the queue if you want to use a https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-basic-examples-of-sqs-policies.html#grant-two-permissions-to-one-account[cross-account queue] with embedded policy. Note that AWS SDK only support numerical account ID and not account aliases.
199
+
191
200
  [id="plugins-{type}s-{plugin}-region"]
192
201
  ===== `region`
193
202
 
@@ -83,6 +83,9 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
83
83
  # 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
84
  config :queue, :validate => :string, :required => true
85
85
 
86
+ # Account ID of the AWS account which owns the queue.
87
+ config :queue_owner_aws_account_id, :validate => :string, :required => false
88
+
86
89
  # Name of the event field in which to store the SQS message ID
87
90
  config :id_field, :validate => :string
88
91
 
@@ -99,15 +102,22 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
99
102
 
100
103
  def register
101
104
  require "aws-sdk"
102
- @logger.info("Registering SQS input", :queue => @queue)
105
+ @logger.info("Registering SQS input", :queue => @queue, :queue_owner_aws_account_id => @queue_owner_aws_account_id)
103
106
 
104
107
  setup_queue
105
108
  end
106
109
 
110
+ def queue_url(aws_sqs_client)
111
+ if @queue_owner_aws_account_id
112
+ return aws_sqs_client.get_queue_url({:queue_name => @queue, :queue_owner_aws_account_id => @queue_owner_aws_account_id})[:queue_url]
113
+ else
114
+ return aws_sqs_client.get_queue_url(:queue_name => @queue)[:queue_url]
115
+ end
116
+ end
117
+
107
118
  def setup_queue
108
119
  aws_sqs_client = Aws::SQS::Client.new(aws_options_hash)
109
- queue_url = aws_sqs_client.get_queue_url(:queue_name => @queue)[:queue_url]
110
- @poller = Aws::SQS::QueuePoller.new(queue_url, :client => aws_sqs_client)
120
+ @poller = Aws::SQS::QueuePoller.new(queue_url(aws_sqs_client), :client => aws_sqs_client)
111
121
  rescue Aws::SQS::Errors::ServiceError, Seahorse::Client::NetworkingError => e
112
122
  @logger.error("Cannot establish connection to Amazon SQS", exception_details(e))
113
123
  raise LogStash::ConfigurationError, "Verify the SQS queue name and your credentials"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-sqs'
3
- s.version = '3.1.3'
3
+ s.version = '3.2.0'
4
4
  s.licenses = ['Apache License (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"
@@ -49,6 +49,24 @@ describe LogStash::Inputs::SQS do
49
49
  expect { subject.register }.not_to raise_error
50
50
  end
51
51
 
52
+ context "when queue_aws_account_id option is specified" do
53
+ let(:queue_account_id) { "123456789012" }
54
+ let(:config) do
55
+ {
56
+ "region" => "us-east-1",
57
+ "access_key_id" => "123",
58
+ "secret_access_key" => "secret",
59
+ "queue" => queue_name,
60
+ "queue_owner_aws_account_id" => queue_account_id
61
+ }
62
+ end
63
+ it "passes the option to sqs client" do
64
+ expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
65
+ expect(mock_sqs).to receive(:get_queue_url).with({ :queue_name => queue_name, :queue_owner_aws_account_id => queue_account_id }).and_return({:queue_url => queue_url })
66
+ expect { subject.register }.not_to raise_error
67
+ end
68
+ end
69
+
52
70
  context "when interrupting the plugin" do
53
71
  before do
54
72
  expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
@@ -157,7 +175,7 @@ describe LogStash::Inputs::SQS do
157
175
 
158
176
  context 'can create multiple events' do
159
177
  require "logstash/codecs/json_lines"
160
- let(:config) { super.merge({ "codec" => "json_lines" }) }
178
+ let(:config) { super().merge({ "codec" => "json_lines" }) }
161
179
  let(:first_message) { { "sequence" => "first" } }
162
180
  let(:second_message) { { "sequence" => "second" } }
163
181
  let(:encoded_message) { double("sqs_message", :body => "#{LogStash::Json::dump(first_message)}\n#{LogStash::Json::dump(second_message)}\n") }
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.1.3
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2022-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -129,8 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.6.13
132
+ rubygems_version: 3.1.6
134
133
  signing_key:
135
134
  specification_version: 4
136
135
  summary: Pulls events from an Amazon Web Services Simple Queue Service queue