MovableInkAWS 2.3.0 → 2.4.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: 46d76e882265a792568c24853fbc6953bcfa54c4677d67b8aaf97d009896cb24
4
- data.tar.gz: f02414993d6c9509bd72f5ec246e6bf99fc60c20a036487be9336cb41e780e8f
3
+ metadata.gz: 1c9a86a0ab40e4e623c361481330fd62111efa6d6f62cb79e1959d2ef49c9824
4
+ data.tar.gz: 0c792c6c2775ab5d6bc6d838713059a68313e1e5bac7e461757595e5b53ff166
5
5
  SHA512:
6
- metadata.gz: b987bbb77c3fd5d2c1fc23c84c62e3af00df58074dbbdc9db21fd05fc8181c23f10bf096665f197ee98f79deaf4aaaaabc3fea1418ffcb85f0f256145fe13260
7
- data.tar.gz: ddc7c1eff50e05f3d1cd83cb65df72f688c6aadbed822dc3a87cd9e2096451ab23f62293092443f9d22f4e76a84eb7073da2ffb41117987341bfb2663915cc25
6
+ metadata.gz: 470d135f2a065395a53fa0a362f6075cc3755815a0bfd6e426e46427932dcf1eca04af944b50dad190a067a1a8202d8951d027e79949263935f579e93446450c
7
+ data.tar.gz: 45fd5275c71dc36ad59295f660684018f3b5a386cca5d084fada593aaa02260dc4bb2751922462dc702bb8c59e5a0040b040d13a86b933c8414f643c24c143cd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (2.3.0)
4
+ MovableInkAWS (2.4.0)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -12,4 +12,5 @@
12
12
 
13
13
  #### Dependencies (if any)
14
14
 
15
- :house: [chXXXX](https://app.clubhouse.io/movableink/story/XXXX)
15
+
16
+ :house: [sc-XXXX](https://app.shortcut.com/movableink/story/XXXX)
@@ -156,24 +156,24 @@ module MovableInk
156
156
 
157
157
  def map_ec2_consul_endpoint(endpoint)
158
158
  OpenStruct.new ({
159
- private_ip_address: endpoint.Node['Address'],
160
- instance_id: endpoint.Node['Meta']['instance_id'],
159
+ private_ip_address: endpoint.Node.dig('Address'),
160
+ instance_id: endpoint.Node.dig('Meta', 'instance_id'),
161
161
  tags: [
162
162
  {
163
163
  key: 'Name',
164
- value: endpoint.Node['Node']
164
+ value: endpoint.Node.dig('Node')
165
165
  },
166
166
  {
167
167
  key: 'mi:roles',
168
- value: endpoint.Node['Meta']['mi_roles']
168
+ value: endpoint.Node.dig('Meta', 'mi_roles')
169
169
  },
170
170
  {
171
171
  key: 'mi:monitoring_roles',
172
- value: endpoint.Node['Meta']['mi_monitoring_roles']
172
+ value: endpoint.Node.dig('Meta', 'mi_monitoring_roles')
173
173
  }
174
174
  ],
175
175
  placement: {
176
- availability_zone: endpoint.Node['Meta']['availability_zone']
176
+ availability_zone: endpoint.Node.dig('Meta', 'availability_zone')
177
177
  }
178
178
  })
179
179
  end
@@ -34,6 +34,10 @@ module MovableInk
34
34
  @instance_id ||= retrieve_metadata('instance-id')
35
35
  end
36
36
 
37
+ def instance_type
38
+ @instance_type ||= retrieve_metadata('instance-type')
39
+ end
40
+
37
41
  def private_ipv4
38
42
  @ipv4 ||= retrieve_metadata('local-ipv4')
39
43
  end
@@ -43,7 +47,7 @@ module MovableInk
43
47
  def imds_token(tries: 3)
44
48
  tries.times do |num|
45
49
  num += 1
46
- request = Net::HTTP::Get.new('/latest/api/token')
50
+ request = Net::HTTP::Put.new('/latest/api/token')
47
51
  request['X-aws-ec2-metadata-token-ttl-seconds'] = 120
48
52
  response = http(timeout_seconds: num * 3).request(request)
49
53
  return response.body
@@ -65,6 +65,8 @@ module MovableInk
65
65
  rescue Aws::EC2::Errors::RequestLimitExceeded,
66
66
  Aws::EC2::Errors::ResourceAlreadyAssociated,
67
67
  Aws::EC2::Errors::Unavailable,
68
+ Aws::EC2::Errors::InternalError,
69
+ Aws::EC2::Errors::Http503Error,
68
70
  Aws::EKS::Errors::TooManyRequestsException,
69
71
  Aws::SNS::Errors::ThrottledException,
70
72
  Aws::SNS::Errors::Throttling,
@@ -77,6 +79,9 @@ module MovableInk
77
79
  Aws::Route53::Errors::ServiceUnavailable,
78
80
  Aws::SSM::Errors::TooManyUpdates,
79
81
  Aws::SSM::Errors::ThrottlingException,
82
+ Aws::SSM::Errors::InternalServerError,
83
+ Aws::SSM::Errors::Http503Error,
84
+ Aws::SSM::Errors::Http502Error,
80
85
  Aws::Athena::Errors::ThrottlingException,
81
86
  MovableInk::AWS::Errors::NoEnvironmentTagError
82
87
  sleep_time = (num+1)**2 + rand(10)
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '2.3.0'
3
+ VERSION = '2.4.0'
4
4
  end
5
5
  end
data/spec/aws_spec.rb CHANGED
@@ -23,7 +23,7 @@ describe MovableInk::AWS do
23
23
  it 'raises when AWS_REGION is not set and the metadata service is not available' do
24
24
  miaws = MovableInk::AWS.new
25
25
  # stub an error making a request to the metadata api
26
- stub_request(:get, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
26
+ stub_request(:put, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
27
27
  expect { miaws.my_region }.to raise_error(MovableInk::AWS::Errors::MetadataTimeout)
28
28
  end
29
29
  end
data/spec/ec2_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe MovableInk::AWS::EC2 do
10
10
  it "should raise an error if trying to load mi_env outside of EC2" do
11
11
  aws = MovableInk::AWS.new
12
12
  # stub an error making a request to the metadata api
13
- stub_request(:get, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
13
+ stub_request(:put, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
14
14
  expect{ aws.mi_env }.to raise_error(MovableInk::AWS::Errors::MetadataTimeout)
15
15
  end
16
16
 
@@ -22,7 +22,7 @@ describe MovableInk::AWS::EC2 do
22
22
  it "should not find a 'me'" do
23
23
  aws = MovableInk::AWS.new
24
24
  # stub an error making a request to the metadata api
25
- stub_request(:get, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
25
+ stub_request(:put, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
26
26
  expect(aws.me).to eq(nil)
27
27
  end
28
28
  end
@@ -482,6 +482,7 @@ describe MovableInk::AWS::EC2 do
482
482
 
483
483
  ojos_instances = aws.instances(role: 'ojos', availability_zone: other_availability_zone, discovery_type: 'consul')
484
484
  expect(ojos_instances.map{|i| i.tags.first[:value]}).to eq(['ojos_instance2', 'ojos_instance3'])
485
+ expect(ojos_instances.map{|i| i.tags[1][:value]}).to eq(['ojos', 'ojos'])
485
486
  end
486
487
 
487
488
  it "returns backends that are synced from consul-k8s" do
@@ -10,7 +10,7 @@ describe MovableInk::AWS::Metadata do
10
10
  it 'should raise an error if the metadata service times out' do
11
11
  aws = MovableInk::AWS.new
12
12
  # stub an error making a request to the metadata api
13
- stub_request(:get, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
13
+ stub_request(:put, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
14
14
  expect{ aws.instance_id }.to raise_error(MovableInk::AWS::Errors::MetadataTimeout)
15
15
  expect{ aws.availability_zone }.to raise_error(MovableInk::AWS::Errors::MetadataTimeout)
16
16
  end
@@ -18,7 +18,7 @@ describe MovableInk::AWS::Metadata do
18
18
  it 'should raise an error if trying to load private_ipv4 outside of EC2' do
19
19
  aws = MovableInk::AWS.new
20
20
  # stub an error making a request to the metadata api
21
- stub_request(:get, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
21
+ stub_request(:put, 'http://169.254.169.254/latest/api/token').to_raise(Net::OpenTimeout)
22
22
  expect{ aws.private_ipv4 }.to raise_error(MovableInk::AWS::Errors::MetadataTimeout)
23
23
  end
24
24
  end
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.3.0
4
+ version: 2.4.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-04-16 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core