modify_image_attribute ( $image_id, $opt )

The ModifyImageAttribute operation modifies an attribute of an AMI.

Access

public

Parameters

Parameter

Type

Required

Description

$image_id

string

Required

The ID of the AMI whose attribute you want to modify.

$opt

array

Optional

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

  • Attribute - string - Optional - The name of the AMI attribute you want to modify. Available attributes: launchPermission, productCodes
  • OperationType - string - Optional - The type of operation being requested. Available operation types: add, remove
  • UserId - string|array - Optional - The AWS user ID being added to or removed from the list of users with launch permissions for this AMI. Only valid when the launchPermission attribute is being modified. Pass a string for a single value, or an indexed array for multiple values.
  • UserGroup - string|array - Optional - The user group being added to or removed from the list of user groups with launch permissions for this AMI. Only valid when the launchPermission attribute is being modified. Available user groups: all Pass a string for a single value, or an indexed array for multiple values.
  • ProductCode - string|array - Optional - The list of product codes being added to or removed from the specified AMI. Only valid when the productCodes attribute is being modified. Pass a string for a single value, or an indexed array for multiple values.
  • Value - string - Optional - The value of the attribute being modified. Only valid when the description attribute is being modified.
  • LaunchPermission - array - Optional -
    • x - array - Optional - This represents a simple array index.
      • Add - array - Optional - Describes a permission to launch an Amazon Machine Image (AMI).
        • x - array - Optional - This represents a simple array index.
          • UserId - string - Optional - The AWS user ID of the user involved in this launch permission.
          • Group - string - Optional - The AWS group of the user involved in this launch permission. Available groups: all
      • Remove - array - Optional - Describes a permission to launch an Amazon Machine Image (AMI).
        • x - array - Optional - This represents a simple array index.
          • UserId - string - Optional - The AWS user ID of the user involved in this launch permission.
          • Group - string - Optional - The AWS group of the user involved in this launch permission. Available groups: all
  • Description.Value - string - Optional - String value
  • 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

Modify an attribute of an image.

$ec2 = new AmazonEC2();

$response = $ec2->modify_image_attribute('ami-42ad462b', array(
	'LaunchPermission' => array(
		'Add' => array(array('Group' => 'all'))
	)
));

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

Changelog

Version

Description

1.3.4

The ModifyImageAttribute operation introduced backwards-incompatible changes in the 2011-02-28 API release. The Attribute parameter is no longer required.

Related Methods

Source

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

public function modify_image_attribute($image_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['ImageId'] = $image_id;
    
    // Optional list (non-map)
    if (isset($opt['UserId']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'UserId' => (is_array($opt['UserId']) ? $opt['UserId'] : array($opt['UserId']))
        )));
        unset($opt['UserId']);
    }
    
    // Optional list (non-map)
    if (isset($opt['UserGroup']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'UserGroup' => (is_array($opt['UserGroup']) ? $opt['UserGroup'] : array($opt['UserGroup']))
        )));
        unset($opt['UserGroup']);
    }
    
    // Optional list (non-map)
    if (isset($opt['ProductCode']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'ProductCode' => (is_array($opt['ProductCode']) ? $opt['ProductCode'] : array($opt['ProductCode']))
        )));
        unset($opt['ProductCode']);
    }
    
    // Optional map (non-list)
    if (isset($opt['LaunchPermission']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'LaunchPermission' => $opt['LaunchPermission']
        )));
        unset($opt['LaunchPermission']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback