MovableInkAWS 2.1.2 → 2.2.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: 6de21c0fdb46ad5c3506f242a6a2732abe711831fbde4b70c72ad24147e37bce
4
- data.tar.gz: 035f21cb39b733f31bc05b86e877cf81cc62b7c2e7a5a80832df2d2ce147053b
3
+ metadata.gz: d7b1d77334dfeeb0283ce569cb62b7bce8a2518de96c73156f2b25693f0a2168
4
+ data.tar.gz: 56b60538a821c7fab3e55ad7ee0a80ac85312ff003521764e0721dcf86d5577c
5
5
  SHA512:
6
- metadata.gz: 65af327d97a4fddc422eac4b212ff9444b4d70e82c045baf4c96627e37152415fa183417399a189aa6c47f26176fab07640662e7a092063f48665bf214b9f13c
7
- data.tar.gz: b91d80649d4f32bd8b878125e1c2d4a9c7fd6825194b82d563c43017897a85b3e784ff2cc6e6c3cb28f714f17a49d0bec57da754b67eea67698a4663cdc9c4a8
6
+ metadata.gz: 4132433dd73377d07d141297180ec17f983c4f124811ef45e474a78aa31d493d44ec2df98ed393707d13b095821182e54fcbcf23eff61f924d915aaf4eec1edd
7
+ data.tar.gz: e317ad0ac916a54ffd6042310906310ea5be40f3b6b88f83b3f8c6b45364bcea3df1282c5106a5d9032cf1804137e1c03002fd0cbc7942142ca2f7ec45245798
@@ -0,0 +1,39 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches: ['**']
6
+ tags: ['v*']
7
+ pull_request:
8
+ branches: [$default-branch]
9
+
10
+ jobs:
11
+ test:
12
+
13
+ runs-on: ubuntu-18.04
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+
18
+ - name: Install ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6
22
+
23
+ - name: Install dependencies
24
+ run: bundle install --retry=3
25
+
26
+ - name: Run tests
27
+ run: bundle exec rspec spec/
28
+
29
+ - name: Publish to RubyGems
30
+ if: startsWith(github.ref, 'refs/tags/')
31
+ run: |
32
+ mkdir -p $HOME/.gem
33
+ touch $HOME/.gem/credentials
34
+ chmod 0600 $HOME/.gem/credentials
35
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
36
+ gem build *.gemspec
37
+ gem push *.gem
38
+ env:
39
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (2.1.2)
4
+ MovableInkAWS (2.2.0)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -29,42 +29,27 @@ module MovableInk
29
29
  sleep seconds
30
30
  end
31
31
 
32
- def notify_nsq_can_not_be_drained
33
- notify_slack(subject: 'NSQ not drained',
34
- message: "Unable to drain NSQ for instance <https://#{my_region}.console.aws.amazon.com/ec2/v2/home?region=#{my_region}#Instances:search=#{instance_id};sort=instanceId|#{instance_id}>")
35
- notify_pagerduty(region: my_region, instance_id: instance_id)
36
- end
37
-
38
- def notify_pagerduty(region:, instance_id:)
39
- summary = "Unable to drain NSQ for instance #{instance_id} in region #{region}"
40
-
41
- # the PagerDuty integration key is added to the payload in the AWS integration
42
- json_message = {
43
- pagerduty: {
44
- event_action: 'trigger',
45
- payload: {
46
- source: 'MovableInkAWS',
47
- summary: summary,
48
- timestamp: Time.now.utc.iso8601,
49
- severity: 'error',
50
- component: 'nsq',
51
- group: 'nsq',
52
- custom_details: {
53
- InstanceId: instance_id,
54
- },
55
- },
56
- dedup_key: "nsq-not-draining-#{instance_id}",
57
- links: [{
58
- href: "https://#{region}.console.aws.amazon.com/ec2/v2/home?region=#{region}#Instances:search=#{instance_id};sort=instanceId",
59
- text: 'View Instance'
60
- }],
61
- }
62
- }.to_json
63
-
32
+ def send_alert(
33
+ source: instance_id,
34
+ links: [],
35
+ custom_details: {},
36
+ summary:,
37
+ dedup_key:
38
+ )
64
39
  run_with_backoff do
65
- sns.publish(topic_arn: sns_pagerduty_topic_arn,
66
- subject: "Unable to drain NSQ",
67
- message: json_message)
40
+ message_json = pd_message_json({
41
+ source: source,
42
+ summary: summary,
43
+ links: links,
44
+ custom_details: custom_details,
45
+ dedup_key: dedup_key,
46
+ })
47
+
48
+ sns.publish({
49
+ topic_arn: sns_pagerduty_topic_arn,
50
+ subject: summary,
51
+ message: message_json
52
+ })
68
53
  end
69
54
  end
70
55
 
@@ -78,6 +63,33 @@ module MovableInk
78
63
  message: "#{required_info}\n#{message}")
79
64
  end
80
65
  end
66
+
67
+ private
68
+
69
+ def pd_message_json(
70
+ source:,
71
+ summary:,
72
+ links:,
73
+ custom_details:,
74
+ dedup_key:
75
+ )
76
+ {
77
+ pagerduty: {
78
+ event_action: 'trigger',
79
+ payload: {
80
+ source: source,
81
+ summary: summary,
82
+ timestamp: Time.now.utc.iso8601,
83
+ severity: 'error',
84
+ component: source,
85
+ group: source,
86
+ custom_details: custom_details,
87
+ },
88
+ dedup_key: dedup_key,
89
+ links: links,
90
+ }
91
+ }.to_json
92
+ end
81
93
  end
82
94
  end
83
95
  end
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '2.1.2'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
data/spec/sns_spec.rb CHANGED
@@ -47,7 +47,7 @@ describe MovableInk::AWS::SNS do
47
47
  allow(aws).to receive(:sns).and_return(sns)
48
48
  allow(aws).to receive(:private_ipv4).and_return('10.0.0.1')
49
49
 
50
- expect(aws.notify_pagerduty(region: 'us-east-1', instance_id: 'i-987654321').message_id).to eq('messageId')
50
+ expect(aws.send_alert(summary: 'Something bad happened', dedup_key: 'i-987654321').message_id).to eq('messageId')
51
51
  end
52
52
 
53
53
  it "should truncate subjects longer than 100 characters" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MovableInkAWS
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Chesler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -227,7 +227,7 @@ extensions: []
227
227
  extra_rdoc_files: []
228
228
  files:
229
229
  - ".github/workflows/pr-lint.yaml"
230
- - ".travis.yml"
230
+ - ".github/workflows/test.yaml"
231
231
  - Gemfile
232
232
  - Gemfile.lock
233
233
  - MovableInkAWS.gemspec
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  - !ruby/object:Gem::Version
277
277
  version: '0'
278
278
  requirements: []
279
- rubygems_version: 3.0.8
279
+ rubygems_version: 3.0.3
280
280
  signing_key:
281
281
  specification_version: 4
282
282
  summary: AWS Utility methods for MovableInk
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.6
5
-
6
- bundler_args: "--retry=3"
7
-
8
- script:
9
- - rspec spec/
10
-
11
- deploy:
12
- provider: rubygems
13
- api_key:
14
- secure: NAHVFo9MwOnAYhq1NzZz22/2p34Iw/L71ZNt2WHSbWuMVnA/xyvVu7Ja/S25aQmaV/btNkxTYtbJbf83QZTO9/IwkashWFcWJtLiptZkBRdpkiunMPWX9Gw3Ap5fODUIPxLFyLYWd53huNBJppBCVQTUPwkLEcWJcQZP4MU7dkhW5QKdQgmyNTlMy8epxyMqCQe7V0n98LCwreUsHxHMToe6/V0FemysjYjpnyNvcFpGFa9kf28VQw8ZpDR0iobw9hg6qs61Xj69Y3ns9fWI3sdnk8VjY29M+V415/ksyn7kzCjYiQsGGCFerzjMffIt/4PXqX81GRvcymxmpXWwtikJYP95kiHYbLGFUNS5GJngbyVgO5+amjx7vSZfaBGSXcUCSkxLV1Ki4QfMYnA4ihogwTdQhIALSEV9GzOfFt147lUok2LgZDzNfn9nCPL+qKMBNaBRe7/YoWGuvLQG/smYjunPYhis0ynAQ1Sytc7lgtbdEtLFzfET87ITVS4Y2F9TQ+z1fxROAn/YwMmdSPyiaXVLEOIUc/gx0BjJneTl43M4l6ZId8Q6maJTNG2Fd0yK0hwLJcsN/257HbnPEiTTgkXBcg58E6/ABfZqwDnJrP3sQPem85M4BxLJIPUvfBkYzyeAEV+ALYDJx+KLaqYCCgavF9M+41VbkkNZyKU=
15
- gem: MovableInkAWS
16
- on:
17
- tags: true
18
- repo: movableink/awslib