Amazon Elastic Compute Cloud

2023/02/14 - Amazon Elastic Compute Cloud - 3 updated api methods

Changes  With this release customers can turn host maintenance on or off when allocating or modifying a supported dedicated host. Host maintenance is turned on by default for supported hosts.

AllocateHosts (updated) Link ¶
Changes (request)
{'HostMaintenance': 'on | off'}

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.

See also: AWS API Documentation

Request Syntax

client.allocate_hosts(
    AutoPlacement='on'|'off',
    AvailabilityZone='string',
    ClientToken='string',
    InstanceType='string',
    InstanceFamily='string',
    Quantity=123,
    TagSpecifications=[
        {
            'ResourceType': 'capacity-reservation'|'client-vpn-endpoint'|'customer-gateway'|'carrier-gateway'|'coip-pool'|'dedicated-host'|'dhcp-options'|'egress-only-internet-gateway'|'elastic-ip'|'elastic-gpu'|'export-image-task'|'export-instance-task'|'fleet'|'fpga-image'|'host-reservation'|'image'|'import-image-task'|'import-snapshot-task'|'instance'|'instance-event-window'|'internet-gateway'|'ipam'|'ipam-pool'|'ipam-scope'|'ipv4pool-ec2'|'ipv6pool-ec2'|'key-pair'|'launch-template'|'local-gateway'|'local-gateway-route-table'|'local-gateway-virtual-interface'|'local-gateway-virtual-interface-group'|'local-gateway-route-table-vpc-association'|'local-gateway-route-table-virtual-interface-group-association'|'natgateway'|'network-acl'|'network-interface'|'network-insights-analysis'|'network-insights-path'|'network-insights-access-scope'|'network-insights-access-scope-analysis'|'placement-group'|'prefix-list'|'replace-root-volume-task'|'reserved-instances'|'route-table'|'security-group'|'security-group-rule'|'snapshot'|'spot-fleet-request'|'spot-instances-request'|'subnet'|'subnet-cidr-reservation'|'traffic-mirror-filter'|'traffic-mirror-session'|'traffic-mirror-target'|'transit-gateway'|'transit-gateway-attachment'|'transit-gateway-connect-peer'|'transit-gateway-multicast-domain'|'transit-gateway-policy-table'|'transit-gateway-route-table'|'transit-gateway-route-table-announcement'|'volume'|'vpc'|'vpc-endpoint'|'vpc-endpoint-connection'|'vpc-endpoint-service'|'vpc-endpoint-service-permission'|'vpc-peering-connection'|'vpn-connection'|'vpn-gateway'|'vpc-flow-log'|'capacity-reservation-fleet'|'traffic-mirror-filter-rule'|'vpc-endpoint-connection-device-type'|'verified-access-instance'|'verified-access-group'|'verified-access-endpoint'|'verified-access-policy'|'verified-access-trust-provider'|'vpn-connection-device-type'|'vpc-block-public-access-exclusion'|'ipam-resource-discovery'|'ipam-resource-discovery-association',
            'Tags': [
                {
                    'Key': 'string',
                    'Value': 'string'
                },
            ]
        },
    ],
    HostRecovery='on'|'off',
    OutpostArn='string',
    HostMaintenance='on'|'off'
)
type AutoPlacement:

string

param 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 auto-placement and affinity in the Amazon EC2 User Guide.

Default: on

type AvailabilityZone:

string

param AvailabilityZone:

[REQUIRED]

The Availability Zone in which to allocate the Dedicated Host.

type ClientToken:

string

param ClientToken:

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

type InstanceType:

string

param 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 InstanceFamily:

string

param 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 Quantity:

integer

param Quantity:

[REQUIRED]

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

type TagSpecifications:

list

param TagSpecifications:

The tags to apply to the Dedicated Host during creation.

  • (dict) --

    The tags to apply to a resource when the resource is being created. When you specify a tag, you must specify the resource type to tag, otherwise the request will fail.

    • ResourceType (string) --

      The type of resource to tag on creation.

    • Tags (list) --

      The tags to apply to the resource.

      • (dict) --

        Describes a tag.

        • Key (string) --

          The key of the tag.

          Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with aws:.

        • Value (string) --

          The value of the tag.

          Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.

type HostRecovery:

string

param 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 EC2 User Guide.

Default: off

type OutpostArn:

string

param OutpostArn:

The Amazon Resource Name (ARN) of the Amazon Web Services Outpost on which to allocate the Dedicated Host.

type HostMaintenance:

string

param HostMaintenance:

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

Default: on

rtype:

dict

returns:

Response Syntax

{
    'HostIds': [
        'string',
    ]
}

Response Structure

  • (dict) --

    Contains the output of AllocateHosts.

    • HostIds (list) --

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

      • (string) --

DescribeHosts (updated) Link ¶
Changes (response)
{'Hosts': {'HostMaintenance': 'on | off'}}

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.

See also: AWS API Documentation

Request Syntax

client.describe_hosts(
    Filter=[
        {
            'Name': 'string',
            'Values': [
                'string',
            ]
        },
    ],
    HostIds=[
        'string',
    ],
    MaxResults=123,
    NextToken='string'
)
type Filter:

list

param Filter:

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

  • (dict) --

    A filter name and value pair that is used to return a more specific list of results from a describe operation. Filters can be used to match a set of resources by specific criteria, such as tags, attributes, or IDs.

    If you specify multiple filters, the filters are joined with an AND, and the request returns only results that match all of the specified filters.

    • Name (string) --

      The name of the filter. Filter names are case-sensitive.

    • Values (list) --

      The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an OR, and the request returns all results that match any of the specified values.

      • (string) --

type HostIds:

list

param HostIds:

The IDs of the Dedicated Hosts. The IDs are used for targeted instance launches.

  • (string) --

type MaxResults:

integer

param MaxResults:

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

type NextToken:

string

param NextToken:

The token to use to retrieve the next page of results.

rtype:

dict

returns:

Response Syntax

{
    'Hosts': [
        {
            'AutoPlacement': 'on'|'off',
            'AvailabilityZone': 'string',
            'AvailableCapacity': {
                'AvailableInstanceCapacity': [
                    {
                        'AvailableCapacity': 123,
                        'InstanceType': 'string',
                        'TotalCapacity': 123
                    },
                ],
                'AvailableVCpus': 123
            },
            'ClientToken': 'string',
            'HostId': 'string',
            'HostProperties': {
                'Cores': 123,
                'InstanceType': 'string',
                'InstanceFamily': 'string',
                'Sockets': 123,
                'TotalVCpus': 123
            },
            'HostReservationId': 'string',
            'Instances': [
                {
                    'InstanceId': 'string',
                    'InstanceType': 'string',
                    'OwnerId': 'string'
                },
            ],
            'State': 'available'|'under-assessment'|'permanent-failure'|'released'|'released-permanent-failure'|'pending',
            'AllocationTime': datetime(2015, 1, 1),
            'ReleaseTime': datetime(2015, 1, 1),
            'Tags': [
                {
                    'Key': 'string',
                    'Value': 'string'
                },
            ],
            'HostRecovery': 'on'|'off',
            'AllowsMultipleInstanceTypes': 'on'|'off',
            'OwnerId': 'string',
            'AvailabilityZoneId': 'string',
            'MemberOfServiceLinkedResourceGroup': True|False,
            'OutpostArn': 'string',
            'HostMaintenance': 'on'|'off'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Hosts (list) --

      Information about the Dedicated Hosts.

      • (dict) --

        Describes the properties of the Dedicated Host.

        • AutoPlacement (string) --

          Whether auto-placement is on or off.

        • AvailabilityZone (string) --

          The Availability Zone of the Dedicated Host.

        • AvailableCapacity (dict) --

          Information about the instances running on the Dedicated Host.

          • AvailableInstanceCapacity (list) --

            The number of instances that can be launched onto the Dedicated Host depending on the host's available capacity. For Dedicated Hosts that support multiple instance types, this parameter represents the number of instances for each instance size that is supported on the host.

            • (dict) --

              Information about the number of instances that can be launched onto the Dedicated Host.

              • AvailableCapacity (integer) --

                The number of instances that can be launched onto the Dedicated Host based on the host's available capacity.

              • InstanceType (string) --

                The instance type supported by the Dedicated Host.

              • TotalCapacity (integer) --

                The total number of instances that can be launched onto the Dedicated Host if there are no instances running on it.

          • AvailableVCpus (integer) --

            The number of vCPUs available for launching instances onto the Dedicated Host.

        • ClientToken (string) --

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

        • HostId (string) --

          The ID of the Dedicated Host.

        • HostProperties (dict) --

          The hardware specifications of the Dedicated Host.

          • Cores (integer) --

            The number of cores on the Dedicated Host.

          • InstanceType (string) --

            The instance type supported by the Dedicated Host. For example, m5.large. If the host supports multiple instance types, no instanceType is returned.

          • InstanceFamily (string) --

            The instance family supported by the Dedicated Host. For example, m5.

          • Sockets (integer) --

            The number of sockets on the Dedicated Host.

          • TotalVCpus (integer) --

            The total number of vCPUs on the Dedicated Host.

        • HostReservationId (string) --

          The reservation ID of the Dedicated Host. This returns a null response if the Dedicated Host doesn't have an associated reservation.

        • Instances (list) --

          The IDs and instance type that are currently running on the Dedicated Host.

          • (dict) --

            Describes an instance running on a Dedicated Host.

            • InstanceId (string) --

              The ID of instance that is running on the Dedicated Host.

            • InstanceType (string) --

              The instance type (for example, m3.medium) of the running instance.

            • OwnerId (string) --

              The ID of the Amazon Web Services account that owns the instance.

        • State (string) --

          The Dedicated Host's state.

        • AllocationTime (datetime) --

          The time that the Dedicated Host was allocated.

        • ReleaseTime (datetime) --

          The time that the Dedicated Host was released.

        • Tags (list) --

          Any tags assigned to the Dedicated Host.

          • (dict) --

            Describes a tag.

            • Key (string) --

              The key of the tag.

              Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with aws:.

            • Value (string) --

              The value of the tag.

              Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.

        • HostRecovery (string) --

          Indicates whether host recovery is enabled or disabled for the Dedicated Host.

        • AllowsMultipleInstanceTypes (string) --

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

        • OwnerId (string) --

          The ID of the Amazon Web Services account that owns the Dedicated Host.

        • AvailabilityZoneId (string) --

          The ID of the Availability Zone in which the Dedicated Host is allocated.

        • MemberOfServiceLinkedResourceGroup (boolean) --

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

        • OutpostArn (string) --

          The Amazon Resource Name (ARN) of the Amazon Web Services Outpost on which the Dedicated Host is allocated.

        • HostMaintenance (string) --

          Indicates whether host maintenance is enabled or disabled for the Dedicated Host.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

ModifyHosts (updated) Link ¶
Changes (request)
{'HostMaintenance': 'on | off'}

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.

See also: AWS API Documentation

Request Syntax

client.modify_hosts(
    AutoPlacement='on'|'off',
    HostIds=[
        'string',
    ],
    HostRecovery='on'|'off',
    InstanceType='string',
    InstanceFamily='string',
    HostMaintenance='on'|'off'
)
type AutoPlacement:

string

param AutoPlacement:

Specify whether to enable or disable auto-placement.

type HostIds:

list

param HostIds:

[REQUIRED]

The IDs of the Dedicated Hosts to modify.

  • (string) --

type HostRecovery:

string

param HostRecovery:

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

type InstanceType:

string

param InstanceType:

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.

type InstanceFamily:

string

param InstanceFamily:

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.

type HostMaintenance:

string

param HostMaintenance:

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

rtype:

dict

returns:

Response Syntax

{
    'Successful': [
        'string',
    ],
    'Unsuccessful': [
        {
            'Error': {
                'Code': 'string',
                'Message': 'string'
            },
            'ResourceId': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Successful (list) --

      The IDs of the Dedicated Hosts that were successfully modified.

      • (string) --

    • Unsuccessful (list) --

      The IDs of the Dedicated Hosts that could not be modified. Check whether the setting you requested can be used.

      • (dict) --

        Information about items that were not successfully processed in a batch call.

        • Error (dict) --

          Information about the error.

          • Code (string) --

            The error code.

          • Message (string) --

            The error message accompanying the error code.

        • ResourceId (string) --

          The ID of the resource.