AllocateHosts - Amazon Elastic Compute Cloud

AllocateHosts

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.

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.

AutoPlacement

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 Instance Placement and Host Affinity in the Amazon EC2 User Guide for Linux Instances.

Default: on

Type: String

Valid Values: on | off

Required: No

AvailabilityZone

The Availability Zone in which to allocate the Dedicated Host.

Type: String

Required: Yes

ClientToken

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

Type: String

Required: No

HostRecovery

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 Elastic Compute Cloud User Guide.

Default: off

Type: String

Valid Values: on | off

Required: No

InstanceFamily

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.

Type: String

Required: No

InstanceType

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.

Type: String

Required: No

Quantity

The number of Dedicated Hosts to allocate to your account with these parameters.

Type: Integer

Required: Yes

TagSpecification.N

The tags to apply to the Dedicated Host during creation.

Type: Array of TagSpecification objects

Required: No

Response Elements

The following elements are returned by the service.

hostIdSet

The ID of the allocated Dedicated Host. This is used to launch an instance onto a specific host.

Type: Array of strings

requestId

The ID of the request.

Type: String

Errors

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

Examples

Example 1

This example allocates a Dedicated Host to your account, on to which you can launch only m5.large instances.

Sample Request

https://ec2.amazonaws.com/?Action=AllocateHosts &AvailabilityZone=us-east-1b &InstanceType=m5.large &Quantity=1 &AUTHPARAMS

Sample Response

<AllocateHostsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <hostIdSet> <item>h-00548908djdsgfs</item> </hostIdSet> </AllocateHostsResponse>

Example 2

This example allocates a Dedicated Host to your account, on to which you can launch multiple instance types in the m5 instance family.

Sample Request

https://ec2.amazonaws.com/?Action=AllocateHosts &AvailabilityZone=us-east-1b &InstanceFamily=m5 &Quantity=1 &AUTHPARAMS

Sample Response

<AllocateHostsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <hostIdSet> <item>h-00548908djdsgfs</item> </hostIdSet> </AllocateHostsResponse>

Example 3

This example allocates a Dedicated Host to your account with host recovery on.

Sample Request

https://ec2.amazonaws.com/?Action=AllocateHosts &AvailabilityZone=us-east-1b &InstanceType=m5.large &Quantity=1 &HostRecovery=on &AUTHPARAMS

Sample Response

<AllocateHostsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <hostIdSet> <item>h-00548908djdsgfs</item> </hostIdSet> </AllocateHostsResponse>

Example 4

This example allocates a Dedicated Host to your account with auto-placement off.

Sample Request

https://ec2.amazonaws.com/?Action=AllocateHosts &AvailabilityZone=us-east-1b &InstanceFamily=m5 &Quantity=1 &AutoPlacement=off &AUTHPARAMS

Sample Response

<AllocateHostsResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>d4904fd9-82c2-4ea5-adfe-a9cc3EXAMPLE</requestId> <hostIdSet> <item>h-00548908djdsgfs</item> </hostIdSet> </AllocateHostsResponse>

Example 5

This example allocates a Dedicated Host to your account, on to which you can launch only m5.2xlarge instances, and applies a tag with a key of purpose and a value of production.

Sample Request

https://ec2.amazonaws.com/?Action=AllocateHosts &AvailabilityZone=us-east-1b &InstanceType=m5.2xlarge &Quantity=1 &TagSpecification.1.ResourceType=dedicated-host &TagSpecification.1.Tag.1.Key=purpose &TagSpecification.1.Tag.1.Value=production &AUTHPARAMS

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: