MovableInkAWS 1.2.1 → 1.3.3

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: 32f0128dbec1cd17ff123d1677590c3874e5f496eb37f43ba39f88c336a1b49b
4
- data.tar.gz: 0d63db5f6abcfd22ad0eecd0d0b401ce7fc943c957960b4d81b2fd6e8a18f44a
3
+ metadata.gz: a474efe41182db10e521fd3df11b259261591f6113f2ab71cf66b0e603199578
4
+ data.tar.gz: 527f38ea7a18d93366b1fe9cbf16f75c3d8f79c8d6f29d6b44e8a4b7eb92d82f
5
5
  SHA512:
6
- metadata.gz: c9477086c54eac4049df764da7f7716384dbf53df4cf7865d861ce376b55c3ca3f3867195c514385b565836b8eafe3e7c08a69ec6fc160c238892ea594c95d9a
7
- data.tar.gz: 8ca9d5b5c39c7772cf5dfa6b9a746aaa714f9ec636a3e9c3742cd586c0e7e6aa7a35268a690d4a9364d6d56107a87f620e0bd8170271ef29a0587113a267fb51
6
+ metadata.gz: 778adf6177659e449ee6a4c4fea6007120d7397bd5acd109111dfaf3f673af6289e1e9b82f8b8c2a34583c86d9b567283836cedbaa822a183bdd730b074fb9e7
7
+ data.tar.gz: 6f94b899d09790472b843e2fd69f895ed349f97a4b21443d413b61713d464c8eb864cdfce1a495139a2eb67c31cd36ab3fe0f485d333ab2b5f58e178c87ee167
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.5
5
4
  - 2.6
6
5
 
7
6
  bundler_args: "--retry=3"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (1.2.1)
4
+ MovableInkAWS (1.3.3)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -21,50 +21,50 @@ GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
23
  aws-eventstream (1.1.0)
24
- aws-partitions (1.353.0)
25
- aws-sdk-athena (1.30.0)
26
- aws-sdk-core (~> 3, >= 3.99.0)
24
+ aws-partitions (1.383.0)
25
+ aws-sdk-athena (1.33.0)
26
+ aws-sdk-core (~> 3, >= 3.109.0)
27
27
  aws-sigv4 (~> 1.1)
28
- aws-sdk-autoscaling (1.44.0)
29
- aws-sdk-core (~> 3, >= 3.99.0)
28
+ aws-sdk-autoscaling (1.47.0)
29
+ aws-sdk-core (~> 3, >= 3.109.0)
30
30
  aws-sigv4 (~> 1.1)
31
- aws-sdk-cloudwatch (1.42.0)
32
- aws-sdk-core (~> 3, >= 3.99.0)
31
+ aws-sdk-cloudwatch (1.45.0)
32
+ aws-sdk-core (~> 3, >= 3.109.0)
33
33
  aws-sigv4 (~> 1.1)
34
- aws-sdk-core (3.104.3)
34
+ aws-sdk-core (3.109.1)
35
35
  aws-eventstream (~> 1, >= 1.0.2)
36
36
  aws-partitions (~> 1, >= 1.239.0)
37
37
  aws-sigv4 (~> 1.1)
38
38
  jmespath (~> 1.0)
39
- aws-sdk-ec2 (1.183.0)
40
- aws-sdk-core (~> 3, >= 3.99.0)
39
+ aws-sdk-ec2 (1.200.0)
40
+ aws-sdk-core (~> 3, >= 3.109.0)
41
41
  aws-sigv4 (~> 1.1)
42
- aws-sdk-eks (1.39.0)
43
- aws-sdk-core (~> 3, >= 3.99.0)
42
+ aws-sdk-eks (1.45.0)
43
+ aws-sdk-core (~> 3, >= 3.109.0)
44
44
  aws-sigv4 (~> 1.1)
45
- aws-sdk-elasticache (1.40.0)
46
- aws-sdk-core (~> 3, >= 3.99.0)
45
+ aws-sdk-elasticache (1.44.0)
46
+ aws-sdk-core (~> 3, >= 3.109.0)
47
47
  aws-sigv4 (~> 1.1)
48
- aws-sdk-kms (1.36.0)
49
- aws-sdk-core (~> 3, >= 3.99.0)
48
+ aws-sdk-kms (1.39.0)
49
+ aws-sdk-core (~> 3, >= 3.109.0)
50
50
  aws-sigv4 (~> 1.1)
51
- aws-sdk-rds (1.95.0)
52
- aws-sdk-core (~> 3, >= 3.99.0)
51
+ aws-sdk-rds (1.104.0)
52
+ aws-sdk-core (~> 3, >= 3.109.0)
53
53
  aws-sigv4 (~> 1.1)
54
- aws-sdk-route53 (1.40.0)
55
- aws-sdk-core (~> 3, >= 3.99.0)
54
+ aws-sdk-route53 (1.44.0)
55
+ aws-sdk-core (~> 3, >= 3.109.0)
56
56
  aws-sigv4 (~> 1.1)
57
- aws-sdk-s3 (1.76.0)
58
- aws-sdk-core (~> 3, >= 3.104.1)
57
+ aws-sdk-s3 (1.83.1)
58
+ aws-sdk-core (~> 3, >= 3.109.0)
59
59
  aws-sdk-kms (~> 1)
60
60
  aws-sigv4 (~> 1.1)
61
- aws-sdk-sns (1.29.0)
62
- aws-sdk-core (~> 3, >= 3.99.0)
61
+ aws-sdk-sns (1.33.0)
62
+ aws-sdk-core (~> 3, >= 3.109.0)
63
63
  aws-sigv4 (~> 1.1)
64
- aws-sdk-ssm (1.86.0)
65
- aws-sdk-core (~> 3, >= 3.99.0)
64
+ aws-sdk-ssm (1.95.0)
65
+ aws-sdk-core (~> 3, >= 3.109.0)
66
66
  aws-sigv4 (~> 1.1)
67
- aws-sigv4 (1.2.1)
67
+ aws-sigv4 (1.2.2)
68
68
  aws-eventstream (~> 1, >= 1.0.2)
69
69
  diff-lcs (1.3)
70
70
  httparty (0.16.3)
@@ -64,7 +64,9 @@ module MovableInk
64
64
  rescue Aws::EC2::Errors::RequestLimitExceeded,
65
65
  Aws::EC2::Errors::ResourceAlreadyAssociated,
66
66
  Aws::EC2::Errors::Unavailable,
67
+ Aws::EKS::Errors::TooManyRequestsException,
67
68
  Aws::SNS::Errors::ThrottledException,
69
+ Aws::SNS::Errors::Throttling,
68
70
  Aws::AutoScaling::Errors::Throttling,
69
71
  Aws::AutoScaling::Errors::ThrottledException,
70
72
  Aws::S3::Errors::SlowDown,
@@ -9,13 +9,13 @@ module MovableInk
9
9
  end
10
10
 
11
11
  def mi_env_cache_file_path
12
- '/etc/movableink/mi_env'
12
+ '/etc/movableink/environments.json'
13
13
  end
14
14
 
15
15
  def mi_env
16
16
  @mi_env ||= if File.exist?(mi_env_cache_file_path)
17
- value = File.read(mi_env_cache_file_path)
18
- value.empty? ? load_mi_env : value
17
+ environments = JSON.parse(File.read(mi_env_cache_file_path))
18
+ environments[my_region] || load_mi_env
19
19
  else
20
20
  load_mi_env
21
21
  end
@@ -11,29 +11,20 @@ module MovableInk
11
11
  end
12
12
 
13
13
  def sns_slack_topic_arn
14
- run_with_backoff do
15
- sns.list_topics.each do |resp|
16
- resp.topics.each do |topic|
17
- return topic.topic_arn if topic.topic_arn.include? "slack-aws-alerts"
18
- end
19
- end
20
- end
14
+ @sns_slack_topic_arn ||= sns_topics.detect { |topic| topic.topic_arn.include? "slack-aws-alerts" }.topic_arn rescue nil
21
15
  end
22
16
 
23
17
  def sns_pagerduty_topic_arn
24
- run_with_backoff do
25
- sns.list_topics.each do |resp|
26
- resp.topics.each do |topic|
27
- return topic.topic_arn if topic.topic_arn.include? "pagerduty-custom-alerts"
28
- end
29
- end
30
- end
18
+ @sns_pagerduty_topic_arn ||= sns_topics.detect { |topic| topic.topic_arn.include? "pagerduty-custom-alerts" }.topic_arn rescue nil
19
+ end
20
+
21
+ def sns_topics
22
+ @sns_topics ||= run_with_backoff { sns.list_topics.flat_map(&:topics) }
31
23
  end
32
24
 
33
25
  def notify_and_sleep(seconds, error_class)
34
26
  message = "Throttled by AWS. Sleeping #{seconds} seconds, (#{error_class})"
35
- notify_slack(subject: 'API Throttled',
36
- message: message)
27
+ notify_slack(subject: 'API Throttled', message: message)
37
28
  puts message
38
29
  sleep seconds
39
30
  end
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '1.2.1'
3
+ VERSION = '1.3.3'
4
4
  end
5
5
  end
@@ -32,26 +32,14 @@ describe MovableInk::AWS::EC2 do
32
32
  }
33
33
 
34
34
  it 'will read mi_env from disk when the cache file exists' do
35
+ allow(aws).to receive(:my_region).and_return('us-east-2')
35
36
  f = Tempfile.new('cache')
36
- f.write('staging')
37
+ f.write(JSON.generate({ "us-east-1": "production", "us-west-2": "production", "us-east-2": "staging" }))
37
38
  f.close
38
39
  allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
39
40
  expect(aws.mi_env).to eq('staging')
40
41
  end
41
42
 
42
- it 'will read tag data if the cache file is empty' do
43
- ec2.stub_responses(:describe_tags, tag_data)
44
- allow(aws).to receive(:my_region).and_return('us-east-1')
45
- allow(aws).to receive(:instance_id).and_return('i-12345')
46
- allow(aws).to receive(:ec2).and_return(ec2)
47
-
48
- f = Tempfile.new('cache')
49
- f.write('')
50
- f.close
51
- allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
52
- expect(aws.mi_env).to eq('test')
53
- end
54
-
55
43
  it "should find the environment from the current instance's tags" do
56
44
  ec2.stub_responses(:describe_tags, tag_data)
57
45
  allow(aws).to receive(:my_region).and_return('us-east-1')
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: 1.2.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Chesler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core