Module: AWS::EC2::Instance
- Defined in:
 - lib/AWS/EC2/instances.rb
 
Overview
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 = AWS::EC2::Instance.local_instance_id
Constant Summary collapse
- EC2_META_URL_BASE =
 'http://169.254.169.254/latest/meta-data/'
Class Method Summary collapse
- 
  
    
      .local_instance_id  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the current instance-id when called from a host within EC2.
 - 
  
    
      .local_instance_meta_data  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a hash of all available instance meta data.
 
Class Method Details
.local_instance_id ⇒ Object
Returns the current instance-id when called from a host within EC2.
      248 249 250  | 
    
      # 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 ⇒ Object
Returns a hash of all available instance meta data.
      255 256 257 258 259 260 261 262 263  | 
    
      # File 'lib/AWS/EC2/instances.rb', line 255 def self. = {} Net::HTTP.get(URI.parse(EC2_META_URL_BASE)).split("\n").each do || .merge!({ => Net::HTTP.get(URI.parse(EC2_META_URL_BASE + )) }) end return end  |