alerty-plugin-amazon_sns 0.0.3 → 0.0.4

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: d04674a6f81356f06ab46be77416d30c9351a3b7
4
- data.tar.gz: 733fcfd97577c27f50cd36838f71e7e3ff47d844
3
+ metadata.gz: 7affed57c43644806e084ab6c1bd7ecde314b528
4
+ data.tar.gz: 1cdd6940af0945660871c9f482e40aa178175016
5
5
  SHA512:
6
- metadata.gz: 3737bca15eec4c808df8e05fad01dc19b6878439f2d28684c6a461c1921c33f0f55ba96f025b2914aefbb362ff941b38a859574332aa73c6268065b2f2577173
7
- data.tar.gz: ab17ca34ffd68b66ae40165964794506f642e369bb4c1681b5bfd750795f30477377b10c1509500c2cc2a02bd56dcf7e0f84e0883a37b6f59300b0987a7d0613
6
+ metadata.gz: 280b89e75cfa73263ecddf3a2ced29a066daf543b19be338f510e9871ee9a73624e186c088a944ca06d0e757db8d17176a7626bbd875b6b67868adf440fd7509
7
+ data.tar.gz: 9804c127bba94cdb47c72b02bfd0bc2b1bce98a7667349d1cfb700846a9613351dbdcc8ea30072e6d6821d726107aafa96d48a042d96df34afbcfca60e136433
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ vendor
15
15
  *.swp
16
16
  pkg/
17
17
  .env
18
+ example2.yml
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.4 (2016/03/31)
2
+
3
+ Enhancements:
4
+
5
+ * Guess aws_region from topic_arn as default
6
+
1
7
  # 0.0.3 (2015/08/17)
2
8
 
3
9
  Fixes:
data/README.md CHANGED
@@ -21,9 +21,9 @@ Or install it yourself as:
21
21
  ## Configuration
22
22
 
23
23
  * **type**: must be `amazon_sns`
24
- * **topc_name**: Amazon SNS topic name
24
+ * **topc_arn**: Amazon SNS topic name
25
25
  * **subject**: subject of alert. `${command}` is replaced with a given command, `${hostname}` is replaced with the hostname ran a command
26
- * **aws_region**: AWS Region. (default: ENV["AWS_REGION'])
26
+ * **aws_region**: AWS Region. (default: guess from topic_arn, like arn:aws:sns:us-east-1:<account_id>:<topic_name> => us-east-1)
27
27
  * **aws_access_key_id**: Credential key id (default: ENV['AWS_SECRET_KEY_id'] or ~/.aws/credentials or instance profile on EC2)
28
28
  * **aws_secret_access_key**: Credential secret access_key (default: ENV['AWS_SECRET_ACCESS_KEY'] or ~/.aws/credentials or instance profile on EC2)
29
29
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "alerty-plugin-amazon_sns"
5
- spec.version = "0.0.3"
5
+ spec.version = "0.0.4"
6
6
  spec.authors = ["Naotoshi Seo"]
7
7
  spec.email = ["sonots@gmail.com"]
8
8
 
data/example.yml CHANGED
@@ -2,5 +2,5 @@ log_path: STDOUT
2
2
  log_level: debug
3
3
  plugins:
4
4
  - type: amazon_sns
5
- topic_arn: arn:aws:sns:ap-northeast-1:318088369558:alert
5
+ topic_arn: arn:aws:sns:ap-northeast-1:<account_id>:<topic_name>
6
6
  subject: "FAILURE: [${hostname}] ${command}"
@@ -12,7 +12,7 @@ class Alerty
12
12
  # see http://docs.aws.amazon.com/sdkforruby/api/Aws/SNS/Client.html
13
13
  # ENV or ~/.aws/credentials or instance profile on EC2, or alerty config file
14
14
  params = {}
15
- params[:region] = config.aws_region if config.aws_region
15
+ params[:region] = config.aws_region || guess_region(config.topic_arn)
16
16
  params[:access_key_id] = config.aws_access_key_id if config.aws_access_key_id
17
17
  params[:secret_access_key] = config.aws_secret_access_key if config.aws_secret_access_key
18
18
  @client = Aws::SNS::Client.new(params)
@@ -42,6 +42,11 @@ class Alerty
42
42
 
43
43
  private
44
44
 
45
+ def guess_region(topic_arn)
46
+ # arn:aws:sns:ap-northeast-1:<account_id>:<topic_name>
47
+ topic_arn.split(':')[3]
48
+ end
49
+
45
50
  def expand_placeholder(str, record)
46
51
  str.gsub('${command}', record[:command]).gsub('${hostname}', record[:hostname])
47
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alerty-plugin-amazon_sns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alerty
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.2.2
136
+ rubygems_version: 2.5.1
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Amazon SNS plugin for alerty