Method: CloudProviders::Ec2Instance#initialize

Defined in:
lib/cloud_providers/ec2/ec2_instance.rb

#initialize(raw_response = {}) ⇒ Ec2Instance

Returns a new instance of Ec2Instance.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cloud_providers/ec2/ec2_instance.rb', line 19

def initialize(raw_response={})
  @raw_response = raw_response
  self.instance_id                          = raw_response["instanceId"] rescue nil
  self.security_groups                      = raw_response.groupSet.item.map{|sg| sg.groupId }.sort rescue nil
  self.image_id                             = raw_response["imageId"] rescue nil
  self.private_ip                           = raw_response["privateIpAddress"] rescue nil
  self.dns_name                             = raw_response["dnsName"] rescue nil
  self.instance_type                        = raw_response["instanceType"] rescue nil
  self.public_ip                            = raw_response["ipAddress"] rescue nil
  self.key_name                             = raw_response["keyName"] rescue nil
  self.launch_time                          = raw_response["launchTime"] rescue nil
  self.availability_zones                   = raw_response["placement"]["availabilityZone"] rescue nil
  self.status                               = raw_response["instanceState"]["name"] rescue nil
  self.block_device_mapping                 = raw_response["blockDeviceMapping"] rescue nil
  self.subnet_id                            = raw_response["subnetId"] rescue nil
  # disable_api_termination and instance_initiated_shutdown_behavior don't currently get returned in the request -- you'd need to later call describe_instance_attribute
  self.disable_api_termination              = raw_response["disableApiTermination"] rescue nil
  self.instance_initiated_shutdown_behavior = raw_response["instanceInitiatedShutdownBehavior"] rescue nil
  super
end