Method: CloudMaker::EC2#find_instance

Defined in:
lib/cloud_maker/ec2.rb

#find_instance(instance_id) ⇒ Object

Internal: Find the instance object for an instance ID regardless of what region the instance is in. It looks in the default region (us-east-1) first and then looks in all regions if it’s not there.

Returns nil or an AWS::EC2::Instance



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/cloud_maker/ec2.rb', line 207

def find_instance(instance_id)
  # Check the default region first
  return ec2.instances[instance_id] if ec2.instances[instance_id].exists?

  # If we don't find it there look in every region
  instance = nil
  ec2.regions.each do |region|
    if region.instances[instance_id].exists?
      instance = region.instances[instance_id]
      break
    end
  end

  instance
end