Method: Fog::Compute::AWS::Real#describe_instances

Defined in:
lib/fog/compute/requests/aws/describe_instances.rb

#describe_instances(filters = {}) ⇒ Object

Describe all or specified instances

Parameters

  • filters<~Hash> - List of filters to limit results with

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘requestId’<~String> - Id of request

      • ‘reservationSet’<~Array>:

        • ‘groupSet’<~Array> - Group names for reservation

        • ‘ownerId’<~String> - AWS Access Key ID of reservation owner

        • ‘reservationId’<~String> - Id of the reservation

        • ‘instancesSet’<~Array>:

          • instance<~Hash>:

            • ‘architecture’<~String> - architecture of image in [i386, x86_64]

            • ‘amiLaunchIndex’<~Integer> - reference to instance in launch group

            • ‘blockDeviceMapping’<~Array>

              • ‘attachTime’<~Time> - time of volume attachment

              • ‘deleteOnTermination’<~Boolean> - whether or not to delete volume on termination

              • ‘deviceName’<~String> - specifies how volume is exposed to instance

              • ‘status’<~String> - status of attached volume

              • ‘volumeId’<~String> - Id of attached volume

            • ‘dnsName’<~String> - public dns name, blank until instance is running

            • ‘imageId’<~String> - image id of ami used to launch instance

            • ‘instanceId’<~String> - id of the instance

            • ‘instanceState’<~Hash>:

              • ‘code’<~Integer> - current status code

              • ‘name’<~String> - current status name

            • ‘instanceType’<~String> - type of instance

            • ‘ipAddress’<~String> - public ip address assigned to instance

            • ‘kernelId’<~String> - id of kernel used to launch instance

            • ‘keyName’<~String> - name of key used launch instances or blank

            • ‘launchTime’<~Time> - time instance was launched

            • ‘monitoring’<~Hash>:

              • ‘state’<~Boolean - state of monitoring

            • ‘placement’<~Hash>:

              • ‘availabilityZone’<~String> - Availability zone of the instance

            • ‘productCodes’<~Array> - Product codes for the instance

            • ‘privateDnsName’<~String> - private dns name, blank until instance is running

            • ‘privateIpAddress’<~String> - private ip address assigned to instance

            • ‘rootDeviceName’<~String> - specifies how the root device is exposed to the instance

            • ‘rootDeviceType’<~String> - root device type used by AMI in [ebs, instance-store]

            • ‘ramdiskId’<~String> - Id of ramdisk used to launch instance

            • ‘reason’<~String> - reason for most recent state transition, or blank

Amazon API Reference



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fog/compute/requests/aws/describe_instances.rb', line 55

def describe_instances(filters = {})
  unless filters.is_a?(Hash)
    Formatador.display_line("[yellow][WARN] describe_instances with #{filters.class} param is deprecated, use describe_instances('instance-id' => []) instead[/] [light_black](#{caller.first})[/]")
    filters = {'instance-id' => [*filters]}
  end
  params = {}
  # when seeking single instance id, old param style provides more accurate data sooner
  if filters['instance-id'] && !filters['instance-id'].is_a?(Array)
    params.merge!('InstanceId' => filters.delete('instance-id'))
  end
  params.merge!(Fog::AWS.indexed_filters(filters))

  request({
    'Action'    => 'DescribeInstances',
    :idempotent => true,
    :parser     => Fog::Parsers::Compute::AWS::DescribeInstances.new
  }.merge!(params))
end