Skip to content

modify_hosts async

modify_hosts(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    host_recovery: Optional[HostRecovery] = None,
    instance_type: Optional[String] = None,
    instance_family: Optional[String] = None,
    host_maintenance: Optional[HostMaintenance] = None,
    host_ids: Optional[RequestHostIdList] = None,
    auto_placement: Optional[AutoPlacement] = None,
) -> ModifyHostsResult

Modify the auto-placement setting of a Dedicated Host. When auto-placement is enabled, any instances that you launch with a tenancy of host but without a specific host ID are placed onto any available Dedicated Host in your account that has auto-placement enabled. When auto-placement is disabled, you need to provide a host ID to have the instance launch onto a specific host. If no host ID is provided, the instance is launched onto a suitable host with auto-placement enabled.

You can also use this API action to modify a Dedicated Host to support either multiple instance types in an instance family, or to support a specific instance type only.

Parameters:

  • host_recovery (Optional[HostRecovery], default: None ) –

    Indicates whether to enable or disable host recovery for the Dedicated Host. For more information, see Host recovery in the Amazon EC2 User Guide.

  • instance_type (Optional[String], default: None ) –

    Specifies the instance type to be supported by the Dedicated Host. Specify this parameter to modify a Dedicated Host to support only a specific instance type.

    If you want to modify a Dedicated Host to support multiple instance types in its current instance family, omit this parameter and specify InstanceFamily instead. You cannot specify InstanceType and InstanceFamily in the same request.

  • instance_family (Optional[String], default: None ) –

    Specifies the instance family to be supported by the Dedicated Host. Specify this parameter to modify a Dedicated Host to support multiple instance types within its current instance family.

    If you want to modify a Dedicated Host to support a specific instance type only, omit this parameter and specify InstanceType instead. You cannot specify InstanceFamily and InstanceType in the same request.

  • host_maintenance (Optional[HostMaintenance], default: None ) –

    Indicates whether to enable or disable host maintenance for the Dedicated Host. For more information, see Host maintenance in the Amazon EC2 User Guide.

  • host_ids (Optional[RequestHostIdList], default: None ) –

    The IDs of the Dedicated Hosts to modify.

  • auto_placement (Optional[AutoPlacement], default: None ) –

    Specify whether to enable or disable auto-placement.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def modify_hosts(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    host_recovery: Optional["capo_ec2.types.host_recovery.HostRecovery"] = None,
    instance_type: Optional["capo_ec2.types.string.String"] = None,
    instance_family: Optional["capo_ec2.types.string.String"] = None,
    host_maintenance: Optional[
        "capo_ec2.types.host_maintenance.HostMaintenance"
    ] = None,
    host_ids: Optional[
        "capo_ec2.types.request_host_id_list.RequestHostIdList"
    ] = None,
    auto_placement: Optional["capo_ec2.types.auto_placement.AutoPlacement"] = None,
) -> "capo_ec2.types.modify_hosts_result.ModifyHostsResult":
    """<p>Modify the auto-placement setting of a Dedicated Host. When auto-placement is enabled, any instances that you launch with a tenancy of <code>host</code> but without a specific host ID are placed onto any available Dedicated Host in your account that has auto-placement enabled. When auto-placement is disabled, you need to provide a host ID to have the instance launch onto a specific host. If no host ID is provided, the instance is launched onto a suitable host with auto-placement enabled.</p> <p>You can also use this API action to modify a Dedicated Host to support either multiple instance types in an instance family, or to support a specific instance type only.</p>

    Args:
        host_recovery: <p>Indicates whether to enable or disable host recovery for the Dedicated Host. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-recovery.html">Host recovery</a> in the <i>Amazon EC2 User Guide</i>.</p>
        instance_type: <p>Specifies the instance type to be supported by the Dedicated Host. Specify this parameter to modify a Dedicated Host to support only a specific instance type.</p> <p>If you want to modify a Dedicated Host to support multiple instance types in its current instance family, omit this parameter and specify <b>InstanceFamily</b> instead. You cannot specify <b>InstanceType</b> and <b>InstanceFamily</b> in the same request.</p>
        instance_family: <p>Specifies the instance family to be supported by the Dedicated Host. Specify this parameter to modify a Dedicated Host to support multiple instance types within its current instance family.</p> <p>If you want to modify a Dedicated Host to support a specific instance type only, omit this parameter and specify <b>InstanceType</b> instead. You cannot specify <b>InstanceFamily</b> and <b>InstanceType</b> in the same request.</p>
        host_maintenance: <p>Indicates whether to enable or disable host maintenance for the Dedicated Host. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-maintenance.html">Host maintenance</a> in the <i>Amazon EC2 User Guide</i>.</p>
        host_ids: <p>The IDs of the Dedicated Hosts to modify.</p>
        auto_placement: <p>Specify whether to enable or disable auto-placement.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.modify_hosts_request.ModifyHostsRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.modify_hosts_result.ModifyHostsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.modify_hosts

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.modify_hosts.async_modify_hosts(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyHosts")
    )
    input_: capo_ec2.types.modify_hosts_request.ModifyHostsRequest = {}
    if host_recovery is not None:
        input_["host_recovery"] = host_recovery
    if instance_type is not None:
        input_["instance_type"] = instance_type
    if instance_family is not None:
        input_["instance_family"] = instance_family
    if host_maintenance is not None:
        input_["host_maintenance"] = host_maintenance
    if host_ids is not None:
        input_["host_ids"] = host_ids
    if auto_placement is not None:
        input_["auto_placement"] = auto_placement

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output