sensu-transport-snssqs-ng 2.0.4 → 2.1.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
  SHA1:
3
- metadata.gz: c92289e5673d6c1523eaff67ba2c13811d224b0b
4
- data.tar.gz: 53a04fd08f78ec57eea0e4c07c447809bedc1641
3
+ metadata.gz: 27e2deb012e3d5cb4dd49a1877e847a895adf688
4
+ data.tar.gz: 219f46c7147f5fa6599833dfb9b06bd181a11097
5
5
  SHA512:
6
- metadata.gz: dcf918e8f291f21ec353df00d6dc24c76151e7a21fb9e2c12bcf4eca8d53054446439219d81fe7c3cb532b7d70d91772be59c41bd75fb70409f2e2770a8a7693
7
- data.tar.gz: 1879be3c160435f6724390b10fc1f29cd4c38b06d0ff0c4965f176040f148d9a05f9bf6c5ce9d366290fea74284f10741c99583e449dbff3f482737c17681237
6
+ metadata.gz: 5b701d5a370992d39986cb9042d1de281707e60dcefff2441b5c675450d5706c18e63a09bcaf370bd6f511f4dc9a1d191ab03cced2e8cbc2e3b89bc0be848705
7
+ data.tar.gz: dfc9800a01dd284780f467de14cf39ed436ad6f84467e1502366bdf0a7b53fc80ea2484994b82ca932cf93aa542efe44ac7543176f55a9b319c3d4ea2bca00c1
checksums.yaml.gz.sig CHANGED
Binary file
@@ -36,8 +36,13 @@ module Sensu
36
36
  @keepalives_callback = proc {}
37
37
  # Sensu Windows install does not include a valid cert bundle for AWS
38
38
  Aws.use_bundled_cert! if Gem.win_platform?
39
- @sqs = Aws::SQS::Client.new(region: @settings[:region])
40
- @sns = Aws::SNS::Client.new(region: @settings[:region])
39
+ aws_client_settings = {region: @settings[:region]}
40
+ unless @settings[:access_key_id].nil?
41
+ aws_client_settings[:access_key_id] = @settings[:access_key_id]
42
+ aws_client_settings[:secret_access_key] = @settings[:secret_access_key]
43
+ end
44
+ @sqs = Aws::SQS::Client.new aws_client_settings
45
+ @sns = Aws::SNS::Client.new aws_client_settings
41
46
 
42
47
  # connect to statsd, if necessary
43
48
  @statsd = nil
@@ -175,7 +180,33 @@ module Sensu
175
180
  wait_time_seconds: @settings[:wait_time_seconds],
176
181
  max_number_of_messages: @settings[:max_number_of_messages],
177
182
  )
178
- resp.messages
183
+ resp.messages.select do |msg|
184
+ # switching whether to transform the message based on the existance of message_attributes
185
+ # if this is a raw SNS message, it exists in the root of the message and no conversion is needed
186
+ # if it doesn't, it is an encapsulated messsage (meaning the SNS message is a stringified JSON in the body of the SQS message)
187
+ begin
188
+ if !msg.key? 'message_attributes'
189
+ # extracting original SNS message
190
+ tmp_body = JSON.parse msg.body
191
+ # if there is no Message, this isn't a SNS message and something has gone terribly wrong
192
+ next if tmp_body.key? 'Message'
193
+ # replacing the body with the SNS message (as it would be in a raw delivered SNS-SQS message)
194
+ msg.body = tmp_body['Message']
195
+ msg.message_attributes = {}
196
+ # discarding messages without attributes, since this would lead to an exception in subscribe
197
+ next if tmp_body.key? 'MessageAttributes'
198
+ # parsing the message_attributes
199
+ tmp_body['MessageAttributes'].each do |name, value|
200
+ msg.message_attributes[name] = Aws::SQS::Types::MessageAttributeValue.new
201
+ msg.message_attributes[name].string_value = value['Value']
202
+ msg.message_attributes[name].data_type = 'String'
203
+ end
204
+ end
205
+ msg
206
+ rescue JSON::JSONError => e
207
+ self.logger.info(e)
208
+ end
209
+ end
179
210
  rescue Aws::SQS::Errors::ServiceError => e
180
211
  self.logger.info(e)
181
212
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-transport-snssqs-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troy Ready
@@ -31,7 +31,7 @@ cert_chain:
31
31
  SDfvq2xI1v+iTmBkyYqft23MKnTcc5jJ5Gh0a11a2zUstWaH1XHelXYCx44ZLCtC
32
32
  Q6k=
33
33
  -----END CERTIFICATE-----
34
- date: 2016-11-08 00:00:00.000000000 Z
34
+ date: 2017-04-28 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aws-sdk
metadata.gz.sig CHANGED
Binary file