Skip to main content

hosts

Creates, updates, deletes, gets or lists a hosts resource.

Overview

Namehosts
TypeResource
Idaws.ec2.hosts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
allocation_timestringThe time that the Dedicated Host was allocated.
allows_multiple_instance_typesstringIndicates whether the Dedicated Host supports multiple instance types of the same instance family. If the value is on, the Dedicated Host supports multiple instance types in the instance family. If the value is off, the Dedicated Host supports a single instance type only.
asset_idstringThe ID of the Outpost hardware asset on which the Dedicated Host is allocated.
auto_placementstringWhether auto-placement is on or off.
availability_zonestringThe Availability Zone of the Dedicated Host.
availability_zone_idstringThe ID of the Availability Zone in which the Dedicated Host is allocated.
available_capacitystringInformation about the instances running on the Dedicated Host.
client_tokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.
cpu_optionsstringThe CPU options for the Dedicated Host, including AMD Secure Encrypted Virtualization-Secure Nested Paging (AMD SEV-SNP) settings.
host_idstringThe ID of the Dedicated Host.
host_maintenancestringIndicates whether host maintenance is enabled or disabled for the Dedicated Host.
host_propertiesstringThe hardware specifications of the Dedicated Host.
host_recoverystringIndicates whether host recovery is enabled or disabled for the Dedicated Host.
host_reservation_idstringThe reservation ID of the Dedicated Host. This returns a null response if the Dedicated Host doesn't have an associated reservation.
instancesstringThe IDs and instance type that are currently running on the Dedicated Host.
member_of_service_linked_resource_groupbooleanIndicates whether the Dedicated Host is in a host resource group. If memberOfServiceLinkedResourceGroup is true, the host is in a host resource group; otherwise, it is not.
outpost_arnstringThe Amazon Resource Name (ARN) of the Amazon Web Services Outpost on which the Dedicated Host is allocated.
owner_idstringThe ID of the Amazon Web Services account that owns the Dedicated Host.
release_timestringThe time that the Dedicated Host was released.
statestringThe Dedicated Host's state.
tagsstringAny tags assigned to the Dedicated Host.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_hostsselectregionHostId, NextToken, MaxResults, FilterDescribes the specified Dedicated Hosts or all your Dedicated Hosts. The results describe only the Dedicated Hosts in the Region you're currently using. All listed instances consume capacity on your Dedicated Host. Dedicated Hosts that have recently been released are listed with the state released.
modify_hostsupdateHostId, regionHostRecovery, InstanceType, InstanceFamily, HostMaintenance, AutoPlacementModify 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.
allocate_hostsupdateregionInstanceFamily, TagSpecification, HostRecovery, OutpostArn, HostMaintenance, AssetId, AvailabilityZoneId, CpuOptions, AutoPlacement, ClientToken, InstanceType, Quantity, AvailabilityZoneAllocates 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.
release_hostsexecHostId, regionWhen you no longer want to use an On-Demand Dedicated Host it can be released. On-Demand billing is stopped and the host goes into released state. The host ID of Dedicated Hosts that have been released can no longer be specified in another request, for example, to modify the host. You must stop or terminate all instances on a host before it can be released. When Dedicated Hosts are released, it may take some time for them to stop counting toward your limit and you may receive capacity errors when trying to allocate new Dedicated Hosts. Wait a few minutes and then try again. Released hosts still appear in a DescribeHosts response.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
HostIdarrayThe IDs of the Dedicated Hosts to release.
regionstringAWS region (default: us-east-1)
AssetIdarrayThe 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.
AutoPlacementstringIndicates 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
AvailabilityZonestringThe Availability Zone in which to allocate the Dedicated Host.
AvailabilityZoneIdstringThe ID of the Availability Zone.
ClientTokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency.
CpuOptionsobjectThe CPU configuration options to apply to the Dedicated Host.
FilterarrayThe filters. auto-placement - Whether auto-placement is enabled or disabled (on | off). availability-zone - The Availability Zone of the host. client-token - The idempotency token that you provided when you allocated the host. host-reservation-id - The ID of the reservation assigned to this host. instance-type - The instance type size that the Dedicated Host is configured to support. state - The allocation state of the Dedicated Host (available | under-assessment | permanent-failure | released | released-permanent-failure). tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.
HostIdarrayThe IDs of the Dedicated Hosts. The IDs are used for targeted instance launches.
HostMaintenancestringIndicates whether to enable or disable host maintenance for the Dedicated Host. For more information, see Host maintenance in the Amazon EC2 User Guide.
HostRecoverystringIndicates 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
InstanceFamilystringSpecifies 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.
InstanceTypestringSpecifies 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.
MaxResultsintegerThe maximum number of results to return for the request in a single page. The remaining results can be seen by sending another request with the returned nextToken value. This value can be between 5 and 500. If maxResults is given a larger value than 500, you receive an error. You cannot specify this parameter and the host IDs parameter in the same request.
NextTokenstringThe token to use to retrieve the next page of results.
OutpostArnstringThe 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.
QuantityintegerThe 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.
TagSpecificationarrayThe tags to apply to the Dedicated Host during creation.

SELECT examples

Describes the specified Dedicated Hosts or all your Dedicated Hosts. The results describe only the Dedicated Hosts in the Region you're currently using. All listed instances consume capacity on your Dedicated Host. Dedicated Hosts that have recently been released are listed with the state released.

SELECT
allocation_time,
allows_multiple_instance_types,
asset_id,
auto_placement,
availability_zone,
availability_zone_id,
available_capacity,
client_token,
cpu_options,
host_id,
host_maintenance,
host_properties,
host_recovery,
host_reservation_id,
instances,
member_of_service_linked_resource_group,
outpost_arn,
owner_id,
release_time,
state,
tags
FROM aws.ec2.hosts
WHERE region = '{{ region }}' -- required
AND HostId = '{{ HostId }}'
AND NextToken = '{{ NextToken }}'
AND MaxResults = '{{ MaxResults }}'
AND Filter = '{{ Filter }}'
;

UPDATE examples

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.

UPDATE aws.ec2.hosts
SET
-- No updatable properties
WHERE
HostId = '{{ HostId }}' --required
AND region = '{{ region }}' --required
AND HostRecovery = '{{ HostRecovery}}'
AND InstanceType = '{{ InstanceType}}'
AND InstanceFamily = '{{ InstanceFamily}}'
AND HostMaintenance = '{{ HostMaintenance}}'
AND AutoPlacement = '{{ AutoPlacement}}'
RETURNING
successful,
unsuccessful;

Lifecycle Methods

When you no longer want to use an On-Demand Dedicated Host it can be released. On-Demand billing is stopped and the host goes into released state. The host ID of Dedicated Hosts that have been released can no longer be specified in another request, for example, to modify the host. You must stop or terminate all instances on a host before it can be released. When Dedicated Hosts are released, it may take some time for them to stop counting toward your limit and you may receive capacity errors when trying to allocate new Dedicated Hosts. Wait a few minutes and then try again. Released hosts still appear in a DescribeHosts response.

EXEC aws.ec2.hosts.release_hosts
@HostId='{{ HostId }}' --required,
@region='{{ region }}' --required
;