Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

ModifyInstancePlacement

Set the instance affinity value for a specific stopped instance and modify the instance tenancy setting.

Instance affinity is disabled by default. When instance affinity is host and it is not associated with a specific Dedicated Host, the next time it is launched it will automatically be associated with the host it lands on. This relationship will persist if the instance is stopped/started, or rebooted.

You can modify the host ID associated with a stopped instance. If a stopped instance has a new host ID association, the instance will target that host when restarted.

You can modify the tenancy of a stopped instance with a tenancy of host or dedicated.

Affinity, hostID, and tenancy are not required parameters, but at least one of them must be specified in the request. Affinity and tenancy can be modified in the same request, but tenancy can only be modified on instances that are stopped.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

Affinity

The new affinity setting for the instance.

Type: String

Valid Values: default | host

Required: No

HostId

The ID of the Dedicated Host that the instance will have affinity with.

Type: String

Required: No

InstanceId

The ID of the instance that you are modifying.

Type: String

Required: Yes

Tenancy

The tenancy of the instance that you are modifying.

Type: String

Valid Values: dedicated | host

Required: No

Response Elements

The following elements are returned by the service.

requestId

The ID of the request.

Type: String

return

Is true if the request succeeds, and an error otherwise.

Type: Boolean

Errors

For information about the errors that are common to all actions, see Common Errors.

Example

Example

This example modifies the affinity of instance i-0b33i09 so that it always has affinity with host h-00548908djdsgfs.

Sample Request

Copy
https://ec2.amazonaws.com/?Action=ModifyInstancePlacement &Affinity=host &HostId=h-00548908djdsgfs &InstanceId=i-0b33i09 &AUTHPARAMS

Sample Response

Copy
<ModifyInstancePlacementResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <return>true</item> </ModifyInstancePlacementResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: