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
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.
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.
default | host
The ID of the Dedicated Host that the instance will have affinity with.
The ID of the instance that you are modifying.
The tenancy of the instance that you are modifying.
dedicated | host
The following elements are returned by the service.
The ID of the request.
trueif the request succeeds, and an error otherwise.
For information about the errors that are common to all actions, see Common Errors.
This example modifies the affinity of instance
that it always has affinity with host
https://ec2.amazonaws.com/?Action=ModifyInstancePlacement &Affinity=host &HostId=h-00548908djdsgfs &InstanceId=i-0b33i09 &AUTHPARAMS
<ModifyInstancePlacementResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <return>true</item> </ModifyInstancePlacementResponse>
For more information about using this API in one of the language-specific AWS SDKs, see the following: