Class: Specinfra::Ec2Metadata::Tags
- Inherits:
-
Object
- Object
- Specinfra::Ec2Metadata::Tags
- Defined in:
- lib/specinfra/ec2_metadata/tags.rb,
lib/specinfra/ec2_metadata/tags/version.rb
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(host_inventory) ⇒ Tags
constructor
A new instance of Tags.
Constructor Details
#initialize(host_inventory) ⇒ Tags
Returns a new instance of Tags.
7 8 9 |
# File 'lib/specinfra/ec2_metadata/tags.rb', line 7 def initialize(host_inventory) @host_inventory = host_inventory end |
Instance Method Details
#get ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/specinfra/ec2_metadata/tags.rb', line 11 def get region = @host_inventory['ec2']['placement']['availability-zone'].gsub(/[a-z]$/, '') ec2 = Aws::EC2::Client.new(:region => region) page = ec2.( :filters => [{ :name => 'resource-id', :values => [ @host_inventory['ec2']['instance-id'] ], }] ) = {} page.each do |p| page..each do |t| [t['key']] = t['value'] end end end |