modify_instance_attribute ( $instance_id, $opt )

Modifies an attribute of an instance.

Access

public

Parameters

Parameter

Type

Required

Description

$instance_id

string

Required

The ID of the instance whose attribute is 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: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDevice, blockDeviceMapping [Allowed values: instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized]
  • Value - string - Optional - The new value of the instance attribute being modified. Only valid when kernel, ramdisk, userData, disableApiTermination or instanceInitiateShutdownBehavior is specified as the attribute being modified.
  • BlockDeviceMapping - array - Optional - The new block device mappings for the instance whose attributes are being modified. Only valid when blockDeviceMapping is specified as the attribute being modified.
    • x - array - Optional - This represents a simple array index.
      • DeviceName - string - Optional - The device name (e.g., /dev/sdh) at which the block device is exposed on the instance.
      • Ebs - array - Optional - The EBS instance block device specification describing the EBS block device to map to the specified device name on a running instance.
        • x - array - Optional - This represents a simple array index.
          • VolumeId - string - Optional - The ID of the EBS volume that should be mounted as a block device on an Amazon EC2 instance.
          • DeleteOnTermination - boolean - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination.
      • VirtualName - string - Optional - The virtual device name.
      • NoDevice - string - Optional - When set to the empty string, specifies that the device name in this object should not be mapped to any real device.
  • SourceDestCheck.Value - boolean - Optional - Boolean value
  • DisableApiTermination.Value - boolean - Optional - Boolean value
  • InstanceType.Value - string - Optional - String value
  • Kernel.Value - string - Optional - String value
  • Ramdisk.Value - string - Optional - String value
  • UserData.Value - string - Optional - String value
  • InstanceInitiatedShutdownBehavior.Value - string - Optional - String value
  • GroupId - string|array - Optional - Pass a string for a single value, or an indexed array for multiple values.
  • EbsOptimized.Value - boolean - Optional - Boolean 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 on a stopped EBS-backed instance.

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

$response = $ec2->modify_instance_attribute('i-1f549375', array(
	'InstanceType.Value' => 'c1.medium'
));

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

Changelog

Version

Description

1.3.4

The ModifyInstanceAttribute 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 (25 lines) | View on GitHub

public function modify_instance_attribute($instance_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['InstanceId'] = $instance_id;
    
    // Optional list + map
    if (isset($opt['BlockDeviceMapping']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'BlockDeviceMapping' => $opt['BlockDeviceMapping']
        )));
        unset($opt['BlockDeviceMapping']);
    }
    
    // Optional list (non-map)
    if (isset($opt['GroupId']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'GroupId' => (is_array($opt['GroupId']) ? $opt['GroupId'] : array($opt['GroupId']))
        )));
        unset($opt['GroupId']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback