aws_info 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00e55aa41f5e36b0e398d0b4e719954aa22fcf65
4
+ data.tar.gz: 8cddd9e4c292e9242c4dcfe114f6a59f9c56bb6a
5
+ SHA512:
6
+ metadata.gz: 1a8701455eb700a23e96a727eb3c0d0860284013d3a5fbe139243d566595ee4d0c2a65c763a41b2a7b17bff7c545fbea399b961f83bfcfba63ad054fa71b4726
7
+ data.tar.gz: 5d86453769569040db6281d04c8407257f0483d2c83b27a36683fd19227aff60a3407ff767dcf387dc335e140ed3137a3f91411b4a1f41b80d25cdfe40474e1b
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aws_info.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 John Thomas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # AwsInfo
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aws_info`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'aws_info'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install aws_info
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
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
+
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
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/aws_info/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aws_info/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aws_info"
8
+ spec.version = AwsInfo::VERSION
9
+ spec.authors = ["John Thomas"]
10
+ spec.email = ["thomas07@vt.edu"]
11
+
12
+ spec.summary = %q{A simple gem to get AWS server info.}
13
+ spec.description = %q{A gem to provide an easy way to load the AWS
14
+ information from a given AWS instance. Automatically detect server IP,
15
+ Region, Availability Zone, etc. as well as instance tags}
16
+ spec.homepage = "https://github.com/thomas07vt/aws_info"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.8"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "aws_info"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require 'aws_info/version'
2
+ require 'aws_info/aws_info'
3
+
4
+ module AwsInfo
5
+ end
@@ -0,0 +1,98 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module AwsInfo
5
+
6
+ class << self
7
+
8
+ def tags
9
+ @@tags ||= load_tag_data
10
+ end
11
+
12
+ def info
13
+ @@info ||= load_meta_data
14
+ end
15
+
16
+ def region
17
+ info["region"]
18
+ end
19
+
20
+ def ip
21
+ info["privateIp"]
22
+ end
23
+
24
+ def availability_zone
25
+ info["availabilityZone"]
26
+ end
27
+
28
+ def instance_id
29
+ info["instanceId"]
30
+ end
31
+
32
+ def instance_type
33
+ info["instanceType"]
34
+ end
35
+
36
+ def version
37
+ info["version"]
38
+ end
39
+
40
+ def dev_pay_product_codes
41
+ info["devpayProductCodes"]
42
+ end
43
+
44
+ def billing_products
45
+ info["billingProducts"]
46
+ end
47
+
48
+ def account_id
49
+ info["accountId"]
50
+ end
51
+
52
+ def pending_time
53
+ info["pendingTime"]
54
+ end
55
+
56
+ def image_id
57
+ info["imageId"]
58
+ end
59
+
60
+ def kernel_id
61
+ info["kernelId"]
62
+ end
63
+
64
+ def ram_disk_id
65
+ info["ramdiskId"]
66
+ end
67
+
68
+ def architecture
69
+ info["architecture"]
70
+ end
71
+
72
+
73
+
74
+ private
75
+
76
+ def load_tag_data
77
+ tag_array = JSON.parse(query_tag_data)["Tags"]
78
+ tag_array.inject({}) { |tags, e| tags[e["Key"]] = e["Value"]; tags }
79
+ end
80
+
81
+ def query_tag_data
82
+ # You must have permissions to run aws ec2 describe-tags
83
+ # Is there a better way to get this without relying on sysyem calls?
84
+ # Aws sdk provides this, but do I want to rely on the aws-adk?
85
+ `aws ec2 describe-tags --region us-east-1 --filter "Name=resource-id,Values=#{instance_id}"`
86
+ end
87
+
88
+ def load_meta_data
89
+ JSON.parse(query_instance_identity)
90
+ end
91
+
92
+ def query_instance_identity
93
+ Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document'))
94
+ end
95
+
96
+ end # End class methods
97
+
98
+ end
@@ -0,0 +1,3 @@
1
+ module AwsInfo
2
+ VERSION = "0.2.0"
3
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aws_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - John Thomas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: |-
42
+ A gem to provide an easy way to load the AWS
43
+ information from a given AWS instance. Automatically detect server IP,
44
+ Region, Availability Zone, etc. as well as instance tags
45
+ email:
46
+ - thomas07@vt.edu
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - ".rspec"
53
+ - ".travis.yml"
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - aws_info.gemspec
59
+ - bin/console
60
+ - bin/setup
61
+ - lib/aws_info.rb
62
+ - lib/aws_info/aws_info.rb
63
+ - lib/aws_info/version.rb
64
+ homepage: https://github.com/thomas07vt/aws_info
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.4.6
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: A simple gem to get AWS server info.
88
+ test_files: []