modify_snapshot_attribute ( $snapshot_id, $opt )

Adds or remove permission settings for the specified snapshot.

Access

public

Parameters

Parameter

Type

Required

Description

$snapshot_id

string

Required

The ID of the EBS snapshot whose attributes are being modified.

$opt

array

Optional

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

  • Attribute - string - Optional - The name of the attribute being modified. Available attribute names: createVolumePermission [Allowed values: productCodes, createVolumePermission]
  • OperationType - string - Optional - The operation to perform on the attribute. Available operation names: add, remove
  • UserId - string|array - Optional - The AWS user IDs to add to or remove from the list of users that have permission to create EBS volumes from the specified snapshot. Currently supports “all”.

    Only valid when the createVolumePermission attribute is being modified.

    Pass a string for a single value, or an indexed array for multiple values.
  • UserGroup - string|array - Optional - The AWS group names to add to or remove from the list of groups that have permission to create EBS volumes from the specified snapshot. Currently supports “all”.

    Only valid when the createVolumePermission attribute is being modified.

    Pass a string for a single value, or an indexed array for multiple values.
  • CreateVolumePermission - array - Optional -
    • x - array - Optional - This represents a simple array index.
      • Add - array - Optional - Describes a permission allowing either a user or group to create a new EBS volume from a snapshot.
        • x - array - Optional - This represents a simple array index.
          • UserId - string - Optional - The user ID of the user that can create volumes from the snapshot.
          • Group - string - Optional - The group that is allowed to create volumes from the snapshot (currently supports “all”).
      • Remove - array - Optional - Describes a permission allowing either a user or group to create a new EBS volume from a snapshot.
        • x - array - Optional - This represents a simple array index.
          • UserId - string - Optional - The user ID of the user that can create volumes from the snapshot.
          • Group - string - Optional - The group that is allowed to create volumes from the snapshot (currently supports “all”).
  • 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 for a snapshot.

// Instantiate the class
$ec2 = new AmazonEC2();

$response = $ec2->modify_snapshot_attribute($snapshot_id, array(
	'CreateVolumePermission' => array(
		'Add' => array(array('UserId' => '960747153117'))
	)
));

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

Changelog

Version

Description

1.4.7

The ModifySnapshotAttribute operation introduced backwards-incompatible changes in the 2011-11-01 API release. Parameters that used to be optional are now required, and the function signature has changed.

Related Methods

Source

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

public function modify_snapshot_attribute($snapshot_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['SnapshotId'] = $snapshot_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 map (non-list)
    if (isset($opt['CreateVolumePermission']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'CreateVolumePermission' => $opt['CreateVolumePermission']
        )));
        unset($opt['CreateVolumePermission']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback