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


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.


The new affinity setting for the instance.

Type: String

Valid Values: default | host

Required: No


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

Type: String

Required: No


The ID of the instance that you are modifying.

Type: String

Required: Yes


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.


The ID of the request.

Type: String


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

Type: Boolean


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



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

Sample Request &Affinity=host &HostId=h-00548908djdsgfs &InstanceId=i-0b33i09 &AUTHPARAMS

Sample Response

<ModifyInstancePlacementResponse xmlns=""> <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: