aws_info 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: cdae514766489bd0b25ed0d78c4a65b5e0ba18b9
4
- data.tar.gz: 0aa4848de5a8100722ecfd3c11695c1bbe94f4a8
3
+ metadata.gz: 4e4f242bbe355cb6c05a2ed2677fca33dd7719df
4
+ data.tar.gz: 93c389b43ea8db5aedfabf1d19ca6e79e34e6209
5
5
  SHA512:
6
- metadata.gz: 3f6fb4e8e3743108a53d3a2b0e1d494b76caea17417af38b2d2d4e25bca17b01d2105e71586677dee67bbe6729afdc404f95f9dcc3727c55a9d19c2c2a569f2c
7
- data.tar.gz: 0c0c98de54258bac5f803db6f1ae137c4cd218389f23449e3aa46aac4cdd90c474a0f40cc5af9363bb2f756afd6dd8627db5b86896fe05c5a9f8801baeaf400d
6
+ metadata.gz: 460e3dbdb6acbda8aac6f9a714a8a7ce5f422bc983b4e8ca3b121ca6ac617a5b7ae222b425bd774f417ce0599aad8381d80d72b7f16f5bfa2d79dfca1748614d
7
+ data.tar.gz: d8de3bd45b054b73cb7ce16ceffaed33f9870d18eb3dba7a00450c7f9167e8560fb5fce7dd0fc0d869274f095de2cb4b096b73051a508c73fb610f4a3bf4bcba
@@ -3,19 +3,24 @@ require 'json'
3
3
  require 'timeout'
4
4
 
5
5
  module AwsInfo
6
+ DEFAULT_REGION = 'us-east-1'
6
7
 
7
8
  class << self
8
9
 
9
10
  def tags
10
- @@tags ||= load_tag_data
11
+ @tags ||= load_tag_data
11
12
  end
12
13
 
13
14
  def info
14
- @@info ||= load_meta_data
15
+ if @info.nil? || @info == {}
16
+ @info = load_meta_data
17
+ else
18
+ @info
19
+ end
15
20
  end
16
21
 
17
22
  def region
18
- info["region"]
23
+ info["region"] || DEFAULT_REGION
19
24
  end
20
25
 
21
26
  def ip
@@ -91,10 +96,13 @@ module AwsInfo
91
96
  end
92
97
 
93
98
  def query_instance_identity
94
- Timeout::timeout(5) {
99
+ Timeout::timeout(1) {
95
100
  url = 'http://169.254.169.254/latest/dynamic/instance-identity/document'
96
101
  Net::HTTP.get(URI.parse(url))
97
102
  }
103
+ rescue => e
104
+ puts 'Could not load AwsInfo. Is 169.254.169.254 reachable?'
105
+ '{}'
98
106
  end
99
107
 
100
108
  end # End class methods
@@ -1,3 +1,3 @@
1
1
  module AwsInfo
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Thomas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler