MovableInkAWS 1.0.10 → 1.0.15

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: 6fc729fe87d17cc2276485195788a711624461c93e3f1a12295cc18f61682167
4
- data.tar.gz: 2a8e6828125fa200cf5519f9798b7c87c384631bfbb12d41cd697b72d8b77724
3
+ metadata.gz: 68e65c324f0ef9ce4d4c2607ecc050ff7ee04070b819200e3ad34805e56f3d0f
4
+ data.tar.gz: 2868c07278470a371c0ac88eb13985566d4a881eb2d944b63a118d45d033844e
5
5
  SHA512:
6
- metadata.gz: 0db5532736c7aee4b4c153c2d33460a866b557fdf74ba1eaee6e2db70f594aac4b5690a0b186f45619e211d80ef2b216840db95d8a89e287508b063dfc9b155d
7
- data.tar.gz: dda1cc313c0a3f04445dba83d7a0497816bd1058400f91b77f04913a4454c1c7a8e4568e6df9d4812fdaf482dd68e8f6dd7fbee80f14fcd73751ab0d1aee49f4
6
+ metadata.gz: e1da5c8861b8cec7a0b60056177b6e1b5121e9c87108bb4385edc4c32786a33f4ad306a0735eb1327c28b32302e26bb9303e61422488cb3010bf2d9b0524203b
7
+ data.tar.gz: bb5bfc766d27391c49e8f981efd0abac83cedb7bac6446dc6b399706b91dc77dc8586c72ae482eb04b4b7734ed398ee620ba9fa8095a3f1ef5e83543f84b463a
@@ -0,0 +1,11 @@
1
+ name: PR Lint
2
+ on:
3
+ pull_request:
4
+ types: [opened, edited, reopened, synchronize]
5
+
6
+ jobs:
7
+ ch_lint_pr:
8
+ name: Clubhouse
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: movableink/pr-clubhouse-lint-action@release
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (1.0.8)
4
+ MovableInkAWS (1.0.15)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
8
8
  aws-sdk-core (~> 3)
9
9
  aws-sdk-ec2 (~> 1)
10
10
  aws-sdk-elasticache (~> 1)
11
+ aws-sdk-rds (~> 1)
11
12
  aws-sdk-route53 (~> 1)
12
13
  aws-sdk-s3 (~> 1)
13
14
  aws-sdk-sns (~> 1)
@@ -18,54 +19,57 @@ PATH
18
19
  GEM
19
20
  remote: https://rubygems.org/
20
21
  specs:
21
- aws-eventstream (1.0.3)
22
- aws-partitions (1.240.0)
23
- aws-sdk-athena (1.21.0)
22
+ aws-eventstream (1.1.0)
23
+ aws-partitions (1.321.0)
24
+ aws-sdk-athena (1.25.0)
24
25
  aws-sdk-core (~> 3, >= 3.71.0)
25
26
  aws-sigv4 (~> 1.1)
26
- aws-sdk-autoscaling (1.29.0)
27
+ aws-sdk-autoscaling (1.36.0)
27
28
  aws-sdk-core (~> 3, >= 3.71.0)
28
29
  aws-sigv4 (~> 1.1)
29
- aws-sdk-cloudwatch (1.30.0)
30
+ aws-sdk-cloudwatch (1.37.0)
30
31
  aws-sdk-core (~> 3, >= 3.71.0)
31
32
  aws-sigv4 (~> 1.1)
32
- aws-sdk-core (3.78.0)
33
- aws-eventstream (~> 1.0, >= 1.0.2)
33
+ aws-sdk-core (3.96.1)
34
+ aws-eventstream (~> 1, >= 1.0.2)
34
35
  aws-partitions (~> 1, >= 1.239.0)
35
36
  aws-sigv4 (~> 1.1)
36
37
  jmespath (~> 1.0)
37
- aws-sdk-ec2 (1.116.0)
38
+ aws-sdk-ec2 (1.163.0)
39
+ aws-sdk-core (~> 3, >= 3.71.0)
40
+ aws-sigv4 (~> 1.1)
41
+ aws-sdk-elasticache (1.34.0)
38
42
  aws-sdk-core (~> 3, >= 3.71.0)
39
43
  aws-sigv4 (~> 1.1)
40
- aws-sdk-elasticache (1.29.0)
44
+ aws-sdk-kms (1.31.0)
41
45
  aws-sdk-core (~> 3, >= 3.71.0)
42
46
  aws-sigv4 (~> 1.1)
43
- aws-sdk-kms (1.25.0)
47
+ aws-sdk-rds (1.84.0)
44
48
  aws-sdk-core (~> 3, >= 3.71.0)
45
49
  aws-sigv4 (~> 1.1)
46
- aws-sdk-route53 (1.30.0)
50
+ aws-sdk-route53 (1.34.0)
47
51
  aws-sdk-core (~> 3, >= 3.71.0)
48
52
  aws-sigv4 (~> 1.1)
49
- aws-sdk-s3 (1.55.0)
50
- aws-sdk-core (~> 3, >= 3.77.0)
53
+ aws-sdk-s3 (1.66.0)
54
+ aws-sdk-core (~> 3, >= 3.96.1)
51
55
  aws-sdk-kms (~> 1)
52
56
  aws-sigv4 (~> 1.1)
53
- aws-sdk-sns (1.20.0)
57
+ aws-sdk-sns (1.23.0)
54
58
  aws-sdk-core (~> 3, >= 3.71.0)
55
59
  aws-sigv4 (~> 1.1)
56
- aws-sdk-ssm (1.61.0)
60
+ aws-sdk-ssm (1.78.0)
57
61
  aws-sdk-core (~> 3, >= 3.71.0)
58
62
  aws-sigv4 (~> 1.1)
59
- aws-sigv4 (1.1.0)
63
+ aws-sigv4 (1.1.3)
60
64
  aws-eventstream (~> 1.0, >= 1.0.2)
61
65
  diff-lcs (1.3)
62
66
  httparty (0.16.3)
63
67
  mime-types (~> 3.0)
64
68
  multi_xml (>= 0.5.2)
65
69
  jmespath (1.4.0)
66
- mime-types (3.3)
70
+ mime-types (3.3.1)
67
71
  mime-types-data (~> 3.2015)
68
- mime-types-data (3.2019.1009)
72
+ mime-types-data (3.2020.0512)
69
73
  multi_xml (0.6.0)
70
74
  rspec (3.9.0)
71
75
  rspec-core (~> 3.9.0)
@@ -89,4 +93,4 @@ DEPENDENCIES
89
93
  rspec (~> 3.6)
90
94
 
91
95
  BUNDLED WITH
92
- 1.17.1
96
+ 1.17.3
@@ -0,0 +1,15 @@
1
+ ## Current Behavior
2
+
3
+
4
+
5
+ ## Why do we need this change?
6
+
7
+
8
+
9
+ ## Implementation Details
10
+
11
+
12
+
13
+ #### Dependencies (if any)
14
+
15
+ :house: [chXXXX](https://app.clubhouse.io/movableink/story/XXXX)
@@ -34,8 +34,18 @@ module MovableInk
34
34
  end
35
35
  end
36
36
 
37
- def initialize(environment: nil, global_service: nil)
37
+ def initialize(
38
+ ipv4: nil,
39
+ environment: nil,
40
+ global_service: nil,
41
+ instance_id: nil,
42
+ availability_zone: nil
43
+ )
38
44
  @mi_env = environment
45
+ @ipv4 = ipv4
46
+ @instance_id = instance_id
47
+ @availability_zone = availability_zone
48
+
39
49
  if global_service
40
50
  @availability_zone = 'us-east-1a'
41
51
  @instance_id = global_service
@@ -49,6 +59,7 @@ module MovableInk
49
59
  return yield
50
60
  rescue Aws::EC2::Errors::RequestLimitExceeded,
51
61
  Aws::EC2::Errors::ResourceAlreadyAssociated,
62
+ Aws::EC2::Errors::Unavailable,
52
63
  Aws::SNS::Errors::ThrottledException,
53
64
  Aws::AutoScaling::Errors::ThrottledException,
54
65
  Aws::S3::Errors::SlowDown,
@@ -8,8 +8,17 @@ module MovableInk
8
8
  @ec2_client[region] ||= Aws::EC2::Client.new(region: region)
9
9
  end
10
10
 
11
+ def mi_env_cache_file_path
12
+ '/etc/movableink/mi_env'
13
+ end
14
+
11
15
  def mi_env
12
- @mi_env ||= load_mi_env
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
19
+ else
20
+ load_mi_env
21
+ end
13
22
  end
14
23
 
15
24
  def load_mi_env
@@ -20,23 +29,12 @@ module MovableInk
20
29
  raise MovableInk::AWS::Errors::NoEnvironmentTagError
21
30
  end
22
31
 
23
- def thopter_filter
24
- [{
25
- name: 'tag:mi:roles',
26
- values: ['*thopter*']
27
- },
28
- {
29
- name: 'tag:mi:env',
30
- values: [mi_env]
31
- },
32
- {
33
- name: 'instance-state-name',
34
- values: ['running']
35
- }]
36
- end
37
-
38
32
  def thopter_instance
39
- @thopter_instance ||= load_all_instances('us-east-1', filter: thopter_filter)
33
+ @thopter_instance ||= all_instances(region: 'us-east-1').select do |instance|
34
+ instance.tags.select{ |tag| tag.key == 'mi:roles' }.detect do |tag|
35
+ tag.value.include?('thopter')
36
+ end
37
+ end
40
38
  end
41
39
 
42
40
  def all_instances(region: my_region, no_filter: false)
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '1.0.10'
3
+ VERSION = '1.0.15'
4
4
  end
5
5
  end
@@ -7,10 +7,14 @@ describe MovableInk::AWS do
7
7
  allow(aws).to receive(:`).with('ec2metadata --instance-id 2>/dev/null').and_return("")
8
8
  allow(aws).to receive(:`).with('ec2metadata --availability-zone 2>/dev/null').and_return("")
9
9
 
10
-
11
10
  expect{ aws.instance_id }.to raise_error(MovableInk::AWS::Errors::EC2Required)
12
11
  expect{ aws.availability_zone }.to raise_error(MovableInk::AWS::Errors::EC2Required)
13
12
  end
13
+
14
+ it 'doesnt raise an error if instance_id is set' do
15
+ aws = MovableInk::AWS.new(instance_id: 'i-987654321')
16
+ expect(aws.instance_id).to eq('i-987654321')
17
+ end
14
18
  end
15
19
 
16
20
  context "inside EC2" do
@@ -37,6 +37,27 @@ describe MovableInk::AWS::EC2 do
37
37
  ])
38
38
  }
39
39
 
40
+ it 'will read mi_env from disk when the cache file exists' do
41
+ f = Tempfile.new('cache')
42
+ f.write('staging')
43
+ f.close
44
+ allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
45
+ expect(aws.mi_env).to eq('staging')
46
+ end
47
+
48
+ it 'will read tag data if the cache file is empty' do
49
+ ec2.stub_responses(:describe_tags, tag_data)
50
+ allow(aws).to receive(:my_region).and_return('us-east-1')
51
+ allow(aws).to receive(:instance_id).and_return('i-12345')
52
+ allow(aws).to receive(:ec2).and_return(ec2)
53
+
54
+ f = Tempfile.new('cache')
55
+ f.write('')
56
+ f.close
57
+ allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
58
+ expect(aws.mi_env).to eq('test')
59
+ end
60
+
40
61
  it "should find the environment from the current instance's tags" do
41
62
  ec2.stub_responses(:describe_tags, tag_data)
42
63
  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.0.10
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Chesler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-26 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -198,10 +198,12 @@ executables: []
198
198
  extensions: []
199
199
  extra_rdoc_files: []
200
200
  files:
201
+ - ".github/workflows/pr-lint.yaml"
201
202
  - ".travis.yml"
202
203
  - Gemfile
203
204
  - Gemfile.lock
204
205
  - MovableInkAWS.gemspec
206
+ - PULL_REQUEST_TEMPLATE.md
205
207
  - README.md
206
208
  - lib/movable_ink/aws.rb
207
209
  - lib/movable_ink/aws/api_gateway.rb