module AWS::EC2::Instance
A set of methods for querying amazon's ec2 meta-data service. Note : This can ONLY be run on an actual running EC2 instance.
Example Class Method Usage : instance_id = ::local_instance_id
Constants
- EC2_META_URL_BASE
Public Class Methods
local_instance_id()
click to toggle source
Returns the current instance-id when called from a host within EC2.
# File lib/AWS/EC2/instances.rb, line 248 def self.local_instance_id Net::HTTP.get URI.parse(EC2_META_URL_BASE + 'instance-id') end
local_instance_meta_data()
click to toggle source
Returns a hash of all available instance meta data.
# File lib/AWS/EC2/instances.rb, line 255 def self.local_instance_meta_data meta_data = {} Net::HTTP.get(URI.parse(EC2_META_URL_BASE)).split("\n").each do |meta_type| meta_data.merge!({meta_type => Net::HTTP.get(URI.parse(EC2_META_URL_BASE + meta_type)) }) end return meta_data end