Skip to content

EC2  >  Operations  >  modify_instance_placement

modify_instance_placement

Operation

modify_instance_placement async

modify_instance_placement(input: ModifyInstancePlacementInput, plugins: list[Plugin] | None = None) -> ModifyInstancePlacementOutput

Modifies the placement attributes for a specified instance. You can do the following:

  • Modify the affinity between an instance and a Dedicated Host. When affinity is set to host and the instance is not associated with a specific Dedicated Host, the next time the instance is started, it is automatically associated with the host on which it lands. If the instance is restarted or rebooted, this relationship persists.

  • Change the Dedicated Host with which an instance is associated.

  • Change the instance tenancy of an instance.

  • Move an instance to or from a placement group.

At least one attribute for affinity, host ID, tenancy, or placement group name must be specified in the request. Affinity and tenancy can be modified in the same request.

To modify the host ID, tenancy, placement group, or partition for an instance, the instance must be in the stopped state.

Parameters:

Name Type Description Default
input ModifyInstancePlacementInput

An instance of ModifyInstancePlacementInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
ModifyInstancePlacementOutput

An instance of ModifyInstancePlacementOutput.

Input

ModifyInstancePlacementInput dataclass

Bases: _SerdeShape

Dataclass for ModifyInstancePlacementInput structure.

Attributes

affinity class-attribute instance-attribute
affinity: str | None = ...

The affinity setting for the instance. For more information, see Host affinity in the Amazon EC2 User Guide.

group_id class-attribute instance-attribute
group_id: str | None = ...

The Group Id of a placement group. You must specify the Placement Group Group Id to launch an instance in a shared placement group.

group_name class-attribute instance-attribute
group_name: str | None = ...

The name of the placement group in which to place the instance. For spread placement groups, the instance must have a tenancy of default. For cluster and partition placement groups, the instance must have a tenancy of default or dedicated.

To remove an instance from a placement group, specify an empty string ("").

host_id class-attribute instance-attribute
host_id: str | None = ...

The ID of the Dedicated Host with which to associate the instance.

host_resource_group_arn class-attribute instance-attribute
host_resource_group_arn: str | None = ...

The ARN of the host resource group in which to place the instance. The instance must have a tenancy of host to specify this parameter.

instance_id class-attribute instance-attribute
instance_id: str | None = ...

The ID of the instance that you are modifying.

partition_number class-attribute instance-attribute
partition_number: int | None = ...

The number of the partition in which to place the instance. Valid only if the placement group strategy is set to partition.

tenancy class-attribute instance-attribute
tenancy: str | None = ...

The tenancy for the instance.

Note

For T3 instances, you must launch the instance on a Dedicated Host to use a tenancy of host. You can't change the tenancy from host to dedicated or default. Attempting to make one of these unsupported tenancy changes results in an InvalidRequest error code.

Output

ModifyInstancePlacementOutput dataclass

Bases: _SerdeShape

Dataclass for ModifyInstancePlacementOutput structure.

Attributes

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

return_ class-attribute instance-attribute
return_: bool | None = ...

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