aws_info 0.2.0 → 0.3.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 +4 -4
- data/.gitignore +2 -0
- data/README.md +59 -7
- data/lib/aws_info/aws_info.rb +6 -2
- data/lib/aws_info/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc98127c424626815792480e2a2cf267b92cbc2
|
4
|
+
data.tar.gz: 5585ef58f1e8a35cba2a09f303c857368e79c00f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02fcb2c0c6d807fd27b984bfa9d545174448599876fefd5ac936c9ea8c25ba1cef4ba7c27e1547ebfc6164a829a40373dd7783e7da53fae514c0c5f31251440d
|
7
|
+
data.tar.gz: 82325b19e6bcb73899e96fd10c6a0405f367e0c52bc150c7c69d1e6d8acaccd16a95b179a72eb96e5e9631cd59ec0151af40b66333cffbf8099a3b3bfbd86a2d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# AwsInfo
|
2
2
|
|
3
|
-
|
3
|
+
A gem to provide an easy way to load the AWS information from a given AWS instance. Automatically detect server IP, Region, Availability Zone, etc. as well as instance tags.
|
4
|
+
|
5
|
+
Under the hood this gem uses the aws meta data lookup url for instance information:
|
6
|
+
http://169.254.169.254/latest/dynamic/instance-identity/document
|
7
|
+
|
8
|
+
And it uses aws describe tags command on the aws server to get a list of tags: "aws ec2 describe-tags ..."
|
4
9
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -22,17 +26,65 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
```ruby
|
30
|
+
require 'aws_info'
|
31
|
+
|
32
|
+
AwsInfo.region
|
33
|
+
#=> "us-east-1"
|
34
|
+
|
35
|
+
AwsInfo.ip
|
36
|
+
#=> "10.10.10.10"
|
37
|
+
|
38
|
+
AwsInfo.availability_zone
|
39
|
+
#=> "us-east-1b"
|
40
|
+
|
41
|
+
AwsInfo.instance_id
|
42
|
+
#=> "i-00000000"
|
43
|
+
|
44
|
+
AwsInfo.instance_type
|
45
|
+
#=> "t2.micro"
|
46
|
+
|
47
|
+
AwsInfo.version
|
48
|
+
#=> "2015-1-21"
|
49
|
+
|
50
|
+
AwsInfo.dev_pay_product_codes
|
51
|
+
#=> nil
|
26
52
|
|
27
|
-
|
53
|
+
AwsInfo.billing_products
|
54
|
+
#=> nil
|
55
|
+
|
56
|
+
AwsInfo.account_id
|
57
|
+
#=> "00000000000"
|
58
|
+
|
59
|
+
AwsInfo.pending_time
|
60
|
+
#=> "2015-09-04T19:03:47Z"
|
61
|
+
|
62
|
+
AwsInfo.image_id
|
63
|
+
#=> "ami-c8888888"
|
64
|
+
|
65
|
+
AwsInfo.kernel_id
|
66
|
+
#=> nil
|
67
|
+
|
68
|
+
AwsInfo.ram_disk_id
|
69
|
+
#=> nil
|
70
|
+
|
71
|
+
AwsInfo.architecture
|
72
|
+
#=> "x86_64"
|
73
|
+
|
74
|
+
AwsInfo.tags
|
75
|
+
#=> { 'my_tag' => 'my tag's value!'}
|
76
|
+
|
77
|
+
# Access a single tag
|
78
|
+
AwsInfo.tags['my_tag']
|
79
|
+
#=> "my tag's value!"
|
80
|
+
|
81
|
+
```
|
28
82
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
83
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
84
|
|
33
85
|
## Contributing
|
34
86
|
|
35
|
-
1. Fork it ( https://github.com/
|
87
|
+
1. Fork it ( https://github.com/thomas07vt/aws_info/fork )
|
36
88
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
89
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
90
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/aws_info/aws_info.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
|
+
require 'timeout'
|
3
4
|
|
4
5
|
module AwsInfo
|
5
6
|
|
@@ -74,7 +75,7 @@ module AwsInfo
|
|
74
75
|
private
|
75
76
|
|
76
77
|
def load_tag_data
|
77
|
-
tag_array = JSON.parse(query_tag_data)["Tags"]
|
78
|
+
tag_array = JSON.parse(query_tag_data)["Tags"] rescue []
|
78
79
|
tag_array.inject({}) { |tags, e| tags[e["Key"]] = e["Value"]; tags }
|
79
80
|
end
|
80
81
|
|
@@ -90,7 +91,10 @@ module AwsInfo
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def query_instance_identity
|
93
|
-
|
94
|
+
Timeout::timeout(5) {
|
95
|
+
url = 'http://169.254.169.254/latest/dynamic/instance-identity/document'
|
96
|
+
Net::HTTP.get(URI.parse(url))
|
97
|
+
}
|
94
98
|
end
|
95
99
|
|
96
100
|
end # End class methods
|
data/lib/aws_info/version.rb
CHANGED
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
|
+
version: 0.3.0
|
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-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|