Skip to content

allocate_hosts async

allocate_hosts(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    instance_family: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    host_recovery: Optional[HostRecovery] = None,
    outpost_arn: Optional[String] = None,
    host_maintenance: Optional[HostMaintenance] = None,
    asset_ids: Optional[AssetIdList] = None,
    availability_zone_id: Optional[AvailabilityZoneId] = None,
    cpu_options: Optional[HostCpuOptionsRequest] = None,
    auto_placement: Optional[AutoPlacement] = None,
    client_token: Optional[String] = None,
    instance_type: Optional[String] = None,
    quantity: Optional[Integer] = None,
    availability_zone: Optional[AvailabilityZoneName] = None,
) -> AllocateHostsResult

Allocates a Dedicated Host to your account. At a minimum, specify the supported instance type or instance family, the Availability Zone in which to allocate the host, and the number of hosts to allocate.

Parameters:

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

    Specifies the instance family to be supported by the Dedicated Hosts. If you specify an instance family, the Dedicated Hosts support multiple instance types within that instance family.

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

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the Dedicated Host during creation.

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

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

    Default: off

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

    The Amazon Resource Name (ARN) of the Amazon Web Services Outpost on which to allocate the Dedicated Host. If you specify OutpostArn, you can optionally specify AssetIds.

    If you are allocating the Dedicated Host in a Region, omit this parameter.

  • 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.

  • asset_ids (Optional[AssetIdList], default: None ) –

    The IDs of the Outpost hardware assets on which to allocate the Dedicated Hosts. Targeting specific hardware assets on an Outpost can help to minimize latency between your workloads. This parameter is supported only if you specify OutpostArn. If you are allocating the Dedicated Hosts in a Region, omit this parameter.

    • If you specify this parameter, you can omit Quantity. In this case, Amazon EC2 allocates a Dedicated Host on each specified hardware asset.

    • If you specify both AssetIds and Quantity, then the value for Quantity must be equal to the number of asset IDs specified.

  • availability_zone_id (Optional[AvailabilityZoneId], default: None ) –

    The ID of the Availability Zone.

  • cpu_options (Optional[HostCpuOptionsRequest], default: None ) –

    The CPU configuration options to apply to the Dedicated Host.

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

    Indicates whether the host accepts any untargeted instance launches that match its instance type configuration, or if it only accepts Host tenancy instance launches that specify its unique host ID. For more information, see Understanding auto-placement and affinity in the Amazon EC2 User Guide.

    Default: off

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

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.

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

    Specifies the instance type to be supported by the Dedicated Hosts. If you specify an instance type, the Dedicated Hosts support instances of the specified instance type only.

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

  • quantity (Optional[Integer], default: None ) –

    The number of Dedicated Hosts to allocate to your account with these parameters. If you are allocating the Dedicated Hosts on an Outpost, and you specify AssetIds, you can omit this parameter. In this case, Amazon EC2 allocates a Dedicated Host on each specified hardware asset. If you specify both AssetIds and Quantity, then the value that you specify for Quantity must be equal to the number of asset IDs specified.

  • availability_zone (Optional[AvailabilityZoneName], default: None ) –

    The Availability Zone in which to allocate the Dedicated Host.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def allocate_hosts(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    instance_family: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    host_recovery: Optional["capo_ec2.types.host_recovery.HostRecovery"] = None,
    outpost_arn: Optional["capo_ec2.types.string.String"] = None,
    host_maintenance: Optional[
        "capo_ec2.types.host_maintenance.HostMaintenance"
    ] = None,
    asset_ids: Optional["capo_ec2.types.asset_id_list.AssetIdList"] = None,
    availability_zone_id: Optional[
        "capo_ec2.types.availability_zone_id.AvailabilityZoneId"
    ] = None,
    cpu_options: Optional[
        "capo_ec2.types.host_cpu_options_request.HostCpuOptionsRequest"
    ] = None,
    auto_placement: Optional["capo_ec2.types.auto_placement.AutoPlacement"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    instance_type: Optional["capo_ec2.types.string.String"] = None,
    quantity: Optional["capo_ec2.types.integer.Integer"] = None,
    availability_zone: Optional[
        "capo_ec2.types.availability_zone_name.AvailabilityZoneName"
    ] = None,
) -> "capo_ec2.types.allocate_hosts_result.AllocateHostsResult":
    """<p>Allocates a Dedicated Host to your account. At a minimum, specify the supported instance type or instance family, the Availability Zone in which to allocate the host, and the number of hosts to allocate.</p>

    Args:
        instance_family: <p>Specifies the instance family to be supported by the Dedicated Hosts. If you specify an instance family, the Dedicated Hosts support multiple instance types within that instance family.</p> <p>If you want the Dedicated Hosts 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>
        tag_specifications: <p>The tags to apply to the Dedicated Host during creation.</p>
        host_recovery: <p>Indicates whether to enable or disable host recovery for the Dedicated Host. Host recovery is disabled by default. 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> <p>Default: <code>off</code> </p>
        outpost_arn: <p>The Amazon Resource Name (ARN) of the Amazon Web Services Outpost on which to allocate the Dedicated Host. If you specify <b>OutpostArn</b>, you can optionally specify <b>AssetIds</b>.</p> <p>If you are allocating the Dedicated Host in a Region, omit this parameter.</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>
        asset_ids: <p>The IDs of the Outpost hardware assets on which to allocate the Dedicated Hosts. Targeting specific hardware assets on an Outpost can help to minimize latency between your workloads. This parameter is supported only if you specify <b>OutpostArn</b>. If you are allocating the Dedicated Hosts in a Region, omit this parameter.</p> <ul> <li> <p>If you specify this parameter, you can omit <b>Quantity</b>. In this case, Amazon EC2 allocates a Dedicated Host on each specified hardware asset.</p> </li> <li> <p>If you specify both <b>AssetIds</b> and <b>Quantity</b>, then the value for <b>Quantity</b> must be equal to the number of asset IDs specified.</p> </li> </ul>
        availability_zone_id: <p>The ID of the Availability Zone.</p>
        cpu_options: <p>The CPU configuration options to apply to the Dedicated Host.</p>
        auto_placement: <p>Indicates whether the host accepts any untargeted instance launches that match its instance type configuration, or if it only accepts Host tenancy instance launches that specify its unique host ID. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/how-dedicated-hosts-work.html#dedicated-hosts-understanding"> Understanding auto-placement and affinity</a> in the <i>Amazon EC2 User Guide</i>.</p> <p>Default: <code>off</code> </p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring Idempotency</a>.</p>
        instance_type: <p>Specifies the instance type to be supported by the Dedicated Hosts. If you specify an instance type, the Dedicated Hosts support instances of the specified instance type only.</p> <p>If you want the Dedicated Hosts to support multiple instance types in a specific 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>
        quantity: <p>The number of Dedicated Hosts to allocate to your account with these parameters. If you are allocating the Dedicated Hosts on an Outpost, and you specify <b>AssetIds</b>, you can omit this parameter. In this case, Amazon EC2 allocates a Dedicated Host on each specified hardware asset. If you specify both <b>AssetIds</b> and <b>Quantity</b>, then the value that you specify for <b>Quantity</b> must be equal to the number of asset IDs specified.</p>
        availability_zone: <p>The Availability Zone in which to allocate the Dedicated Host.</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.allocate_hosts_request.AllocateHostsRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.allocate_hosts_result.AllocateHostsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.allocate_hosts

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AllocateHosts")
    )
    input_: capo_ec2.types.allocate_hosts_request.AllocateHostsRequest = {}
    if instance_family is not None:
        input_["instance_family"] = instance_family
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if host_recovery is not None:
        input_["host_recovery"] = host_recovery
    if outpost_arn is not None:
        input_["outpost_arn"] = outpost_arn
    if host_maintenance is not None:
        input_["host_maintenance"] = host_maintenance
    if asset_ids is not None:
        input_["asset_ids"] = asset_ids
    if availability_zone_id is not None:
        input_["availability_zone_id"] = availability_zone_id
    if cpu_options is not None:
        input_["cpu_options"] = cpu_options
    if auto_placement is not None:
        input_["auto_placement"] = auto_placement
    if client_token is not None:
        input_["client_token"] = client_token
    if instance_type is not None:
        input_["instance_type"] = instance_type
    if quantity is not None:
        input_["quantity"] = quantity
    if availability_zone is not None:
        input_["availability_zone"] = availability_zone

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