fluent-plugin-sns 2.1.7 → 3.1.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
  SHA1:
3
- metadata.gz: 87c37f2b1deda6a5b4805a25b8a41df7fa109b30
4
- data.tar.gz: ed7fcfc6e9b947d1b53124a150c8a5e85475a8f4
3
+ metadata.gz: c35f1599ebe9e156c55ee4e985fea312eaf862ac
4
+ data.tar.gz: 2aa903bae1f77f667a16eea2a64a119fc3b7042e
5
5
  SHA512:
6
- metadata.gz: 34f1045f519263a3731abe878a5208fdad121932e897b92c71f815909b9fdd0deac12f0c4f1573b17c0ea95f87d368ab26c95aa8b86c9084686cb37318731209
7
- data.tar.gz: bfd814e554938853faaf27cad70027f53fb78852a57a6affc23ebff05f7e059257623e1022e0ff8bd435eefa52af721ca2bb9a5bd355da09041c61cd0d0eed13
6
+ metadata.gz: c6dc25c329fd1843ffe7a1ef3f9ada2ffcdbea79d026a70aa1df1912be8cbd874365fdbfeb074eaf69899e89aaf91de2b294a3a369285297412b2694f99c9b23
7
+ data.tar.gz: 9fc5500948a63e3ac492725c3936ab57335fd1693044f13e9e540e6bf100f5695ddc366473d7ff8b57958e7e0dd0495d2b3eff008caa1da17196ee5d7395936a
data/README.rdoc CHANGED
@@ -28,16 +28,9 @@ Send fluent-event as message to amazon SNS.
28
28
 
29
29
  # following attibutes are optional
30
30
 
31
- sns_endpoint {endpointURL}
32
-
33
- ### endpoint list ###
34
- # Asia Pacific (Tokyo) [Default] : sns.ap-northeast-1.amazonaws.com
35
- # Asia Pacific (Singapore) : sns.ap-southeast-1.amazonaws.com
36
- # US-East (Virginia) : sns.us-east-1.amazonaws.com
37
- # US-West (Oregon) : sns.us-west-2.amazonaws.com
38
- # US-West (N.California) : sns.us-west-1.amazonaws.com
39
- # EU-West (Ireland) : sns.eu-west-1.amazonaws.com
40
- # South America (São Paulo) : sns.sa-east-1.amazonaws.com
31
+ # AWS region (defaults to 'ap-northeast-1'), for a list of all available
32
+ # regions see: http://docs.aws.amazon.com/general/latest/gr/rande.html#sns_region
33
+ sns_region {region}
41
34
 
42
35
  sns_subject_template {template_erb_file_path}
43
36
  sns_subject_key {sns_subject_key}
@@ -46,6 +39,12 @@ Send fluent-event as message to amazon SNS.
46
39
  sns_body_template {sns_body_template}
47
40
  sns_body_key {sns_body_key}
48
41
 
42
+ # SNS Message attributes:
43
+ # http://docs.aws.amazon.com/sns/latest/dg/SNSMessageAttributes.html
44
+ # Note that currently only string values are supported.
45
+ sns_message_attributes {attribute: string_value}
46
+ sns_message_attributes_keys {attribute: key_in_record_with_string_value}
47
+
49
48
  proxy http(s)://{url}:{port}
50
49
 
51
50
  </match>
@@ -59,7 +58,7 @@ Send fluent-event as message to amazon SNS.
59
58
  type sns
60
59
 
61
60
  sns_topic_name example
62
-
61
+
63
62
  sns_endpoint sns.ap-northeast-1.amazonaws.com
64
63
 
65
64
  sns_subject_key from
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gemspec.has_rdoc = false
14
14
  gemspec.require_paths = ["lib"]
15
15
  gemspec.add_dependency "fluentd", "~> 0.10.0"
16
- gemspec.add_dependency "aws-sdk-v1", "~> 1"
16
+ gemspec.add_dependency "aws-sdk", "~> 2"
17
17
  gemspec.test_files = Dir["test/**/*.rb"]
18
18
  gemspec.files = Dir["lib/**/*", "test/**/*.rb"] + %w[VERSION AUTHORS Rakefile]
19
19
  gemspec.executables = []
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.7
1
+ 3.1.0
@@ -1,6 +1,6 @@
1
1
  module Fluent
2
2
 
3
- require 'aws-sdk-v1'
3
+ require 'aws-sdk'
4
4
 
5
5
  class SNSOutput < Output
6
6
 
@@ -22,7 +22,11 @@ module Fluent
22
22
  config_param :sns_body_template, :default => nil
23
23
  config_param :sns_body_key, :string, :default => nil
24
24
  config_param :sns_body, :string, :default => nil
25
- config_param :sns_endpoint, :string, :default => 'sns.ap-northeast-1.amazonaws.com'
25
+ config_param :sns_message_attributes, :hash, :default => nil
26
+ config_param :sns_message_attributes_keys, :hash, :default => nil
27
+ config_param :sns_endpoint, :string, :default => 'sns.ap-northeast-1.amazonaws.com',
28
+ :obsoleted => 'Use sns_region instead'
29
+ config_param :sns_region, :string, :default => 'ap-northeast-1'
26
30
  config_param :proxy, :string, :default => ENV['HTTP_PROXY']
27
31
 
28
32
  def configure(conf)
@@ -32,16 +36,18 @@ module Fluent
32
36
  def start
33
37
  super
34
38
  options = {}
35
- options[:sns_endpoint] = @sns_endpoint
36
- options[:proxy_uri] = @proxy
39
+ options[:region] = @sns_region
40
+ options[:http_proxy] = @proxy
37
41
  if @aws_key_id && @aws_sec_key
38
- options[:access_key_id] = @aws_key_id
39
- options[:secret_access_key] = @aws_sec_key
42
+ options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key)
40
43
  end
41
- AWS.config(options)
44
+ Aws.config.update(options)
42
45
 
43
- @sns = AWS::SNS.new
44
- @topic = @sns.topics.find{|topic| @sns_topic_name == topic.name}
46
+ @sns = Aws::SNS::Resource.new
47
+ @topic = @sns.topics.find{|topic| @sns_topic_name == topic.arn.split(":")[-1]}
48
+ if @topic.nil?
49
+ raise ConfigError, "No topic found for topic name #{@sns_topic_name}."
50
+ end
45
51
 
46
52
  @subject_template = nil
47
53
  unless @sns_subject_template.nil?
@@ -68,7 +74,13 @@ module Fluent
68
74
  record['time'] = Time.at(time).localtime
69
75
  body = get_body(record).to_s.force_encoding('UTF-8')
70
76
  subject = get_subject(record).to_s.force_encoding('UTF-8').gsub(/(\r\n|\r|\n)/, '')
71
- @topic.publish( body, :subject => subject )
77
+ message_attributes = get_message_attributes(record)
78
+
79
+ @topic.publish({
80
+ message: body,
81
+ subject: subject,
82
+ message_attributes: message_attributes,
83
+ })
72
84
  }
73
85
  end
74
86
 
@@ -85,5 +97,30 @@ module Fluent
85
97
  end
86
98
  record[@sns_body_key] || @sns_body || record.to_json
87
99
  end
100
+
101
+ def get_message_attributes(record)
102
+ message_attributes = {}
103
+
104
+ if @sns_message_attributes_keys
105
+ @sns_message_attributes_keys.each_pair do |attribute, key|
106
+ value = record[key]
107
+ if value
108
+ message_attributes[attribute] = {
109
+ data_type: "String",
110
+ string_value: value,
111
+ }
112
+ end
113
+ end
114
+ elsif @sns_message_attributes
115
+ @sns_message_attributes.each_pair do |attribute, value|
116
+ message_attributes[attribute] = {
117
+ data_type: "String",
118
+ string_value: value,
119
+ }
120
+ end
121
+ end
122
+ return message_attributes
123
+ end
124
+
88
125
  end
89
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sns
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.7
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Odagiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.10.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: aws-sdk-v1
28
+ name: aws-sdk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1'
33
+ version: '2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1'
40
+ version: '2'
41
41
  description:
42
42
  email: ixixizko@gmail.com
43
43
  executables: []