describe_images ( $opt )

The DescribeImages operation returns information about AMIs, AKIs, and ARIs available to the user. Information returned includes image type, product codes, architecture, and kernel and RAM disk IDs. Images available to the user include public images available for any user to launch, private images owned by the user making the request, and private images owned by other users for which the user has explicit launch permissions.

Launch permissions fall into three categories:

  • Public: The owner of the AMI granted launch permissions for the AMI to the all group. All users have launch permissions for these AMIs.
  • Explicit: The owner of the AMI granted launch permissions to a specific user.
  • Implicit: A user has implicit launch permissions for all AMIs he or she owns.

The list of AMIs returned can be modified by specifying AMI IDs, AMI owners, or users with launch permissions. If no options are specified, Amazon EC2 returns all AMIs for which the user has launch permissions.

If you specify one or more AMI IDs, only AMIs that have the specified IDs are returned. If you specify an invalid AMI ID, a fault is returned. If you specify an AMI ID for which you do not have access, it will not be included in the returned results.

If you specify one or more AMI owners, only AMIs from the specified owners and for which you have access are returned. The results can include the account IDs of the specified owners, amazon for AMIs owned by Amazon or self for AMIs that you own.

If you specify a list of executable users, only users that have launch permissions for the AMIs are returned. You can specify account IDs (if you own the AMI(s)), self for AMIs for which you own or have explicit permissions, or all for public AMIs.

Deregistered images are included in the returned results for an unspecified interval after deregistration.

Access

public

Parameters

Parameter

Type

Required

Description

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • ImageId - string|array - Optional - An optional list of the AMI IDs to describe. If not specified, all AMIs will be described. Pass a string for a single value, or an indexed array for multiple values.
  • Owner - string|array - Optional - The optional list of owners for the described AMIs. The IDs amazon, self, and explicit can be used to include AMIs owned by Amazon, AMIs owned by the user, and AMIs for which the user has explicit launch permissions, respectively. Pass a string for a single value, or an indexed array for multiple values.
  • ExecutableBy - string|array - Optional - The optional list of users with explicit launch permissions for the described AMIs. The user ID can be a user’s account ID, ‘self’ to return AMIs for which the sender of the request has explicit launch permissions, or ‘all’ to return AMIs with public launch permissions. Pass a string for a single value, or an indexed array for multiple values.
  • Filter - array - Optional - A list of filters used to match properties for Images. For a complete reference to the available filter keys for this operation, see the Amazon EC2 API reference.
    • x - array - Optional - This represents a simple array index.
      • Name - string - Optional - Specifies the name of the filter.
      • Value - string|array - Optional - Contains one or more values for the filter. Pass a string for a single value, or an indexed array for multiple values.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Describe all accessible images.

$ec2 = new AmazonEC2();

$response = $ec2->describe_images();

var_dump($response->isOK());
Result:
bool(true)

Describe all images owned by Amazon.

$ec2 = new AmazonEC2();

$response = $ec2->describe_images(array(
	'Owner' => 'amazon'
));

var_dump($response->isOK());
Result:
bool(true)

Describe all images that your account can execute.

$ec2 = new AmazonEC2();

$response = $ec2->describe_images(array(
	'ExecutableBy' => 'self'
));

var_dump($response->isOK());
Result:
bool(true)

Filter accessible images.

$ec2 = new AmazonEC2();

$response = $ec2->describe_images(array(
	'Filter' => array(
		array('Name' => 'architecture',        'Value' => 'x86_64'     ),
		array('Name' => 'image-type',          'Value' => 'machine'    ),
		array('Name' => 'root-device-type',    'Value' => 'ebs'        ),
		array('Name' => 'virtualization-type', 'Value' => 'paravirtual'),
	)
));

var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/ec2.class.php | Toggle source view (42 lines) | View on GitHub

public function describe_images($opt = null)
{
    if (!$opt) $opt = array();
            
    // Optional list (non-map)
    if (isset($opt['ImageId']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'ImageId' => (is_array($opt['ImageId']) ? $opt['ImageId'] : array($opt['ImageId']))
        )));
        unset($opt['ImageId']);
    }
    
    // Optional list (non-map)
    if (isset($opt['Owner']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Owner' => (is_array($opt['Owner']) ? $opt['Owner'] : array($opt['Owner']))
        )));
        unset($opt['Owner']);
    }
    
    // Optional list (non-map)
    if (isset($opt['ExecutableBy']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'ExecutableBy' => (is_array($opt['ExecutableBy']) ? $opt['ExecutableBy'] : array($opt['ExecutableBy']))
        )));
        unset($opt['ExecutableBy']);
    }
    
    // Optional list + map
    if (isset($opt['Filter']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Filter' => $opt['Filter']
        )));
        unset($opt['Filter']);
    }

    return $this->authenticate('DescribeImages', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback