Skip to main content

fleets

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

Overview

Namefleets
TypeResource
Idaws.ec2.fleets

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
activity_statusstringThe progress of the EC2 Fleet. For fleets of type instant, the status is fulfilled after all requests are placed, regardless of whether target capacity is met (this is the only possible status for instant fleets). For fleets of type request or maintain, the status is pending_fulfillment after all requests are placed, fulfilled when the fleet size meets or exceeds target capacity, pending_termination while instances are terminating when fleet size is decreased, and error if there's an error.
client_tokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency. Constraints: Maximum 64 ASCII characters
contextstringReserved.
create_timestringThe creation date and time of the EC2 Fleet.
errorsstringInformation about the instances that could not be launched by the fleet. Valid only when Type is set to instant.
excess_capacity_termination_policystringIndicates whether running instances should be terminated if the target capacity of the EC2 Fleet is decreased below the current size of the EC2 Fleet. Supported only for fleets of type maintain.
fleet_idstringThe ID of the EC2 Fleet.
fleet_statestringThe state of the EC2 Fleet.
fulfilled_capacitynumberThe number of units fulfilled by this request compared to the set target capacity.
fulfilled_on_demand_capacitynumberThe number of units fulfilled by this request compared to the set target On-Demand capacity.
instancesstringInformation about the instances that were launched by the fleet. Valid only when Type is set to instant.
launch_template_configsstringThe launch template and overrides.
on_demand_optionsstringThe allocation strategy of On-Demand Instances in an EC2 Fleet.
replace_unhealthy_instancesbooleanIndicates whether EC2 Fleet should replace unhealthy Spot Instances. Supported only for fleets of type maintain. For more information, see EC2 Fleet health checks in the Amazon EC2 User Guide.
reserved_capacity_optionsstringDefines EC2 Fleet preferences for utilizing reserved capacity when DefaultTargetCapacityType is set to reserved-capacity.
spot_optionsstringThe configuration of Spot Instances in an EC2 Fleet.
tagsstringThe tags for an EC2 Fleet resource.
target_capacity_specificationstringThe number of units to request. You can choose to set the target capacity in terms of instances or a performance characteristic that is important to your application workload, such as vCPUs, memory, or I/O. If the request type is maintain, you can specify a target capacity of 0 and add capacity later.
terminate_instances_with_expirationbooleanIndicates whether running instances should be terminated when the EC2 Fleet expires.
typestringThe type of request. Indicates whether the EC2 Fleet only requests the target capacity, or also attempts to maintain it. If you request a certain target capacity, EC2 Fleet only places the required requests; it does not attempt to replenish instances if capacity is diminished, and it does not submit requests in alternative capacity pools if capacity is unavailable. To maintain a certain target capacity, EC2 Fleet places the required requests to meet this target capacity. It also automatically replenishes any interrupted Spot Instances. Default: maintain.
valid_fromstringThe start date and time of the request, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the request immediately.
valid_untilstringThe end date and time of the request, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new instance requests are placed or able to fulfill the request. The default end date is 7 days from the current date.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_fleetsselectregionDryRun, MaxResults, NextToken, FleetId, FilterDescribes the specified EC2 Fleet or all of your EC2 Fleets. If a fleet is of type instant, you must specify the fleet ID in the request, otherwise the fleet does not appear in the response. For more information, see Describe your EC2 Fleet in the Amazon EC2 User Guide.
create_fleetinsertLaunchTemplateConfigs, TargetCapacitySpecification, regionDryRun, ClientToken, SpotOptions, OnDemandOptions, ReservedCapacityOptions, ExcessCapacityTerminationPolicy, TerminateInstancesWithExpiration, Type, ValidFrom, ValidUntil, ReplaceUnhealthyInstances, TagSpecification, ContextCreates an EC2 Fleet that contains the configuration information for On-Demand Instances and Spot Instances. Instances are launched immediately if there is available capacity. A single EC2 Fleet can include multiple launch specifications that vary by instance type, AMI, Availability Zone, or subnet. For more information, see EC2 Fleet in the Amazon EC2 User Guide.
modify_fleetupdateFleetId, regionDryRun, ExcessCapacityTerminationPolicy, LaunchTemplateConfig, TargetCapacitySpecification, ContextModifies the specified EC2 Fleet. You can only modify an EC2 Fleet request of type maintain. While the EC2 Fleet is being modified, it is in the modifying state. To scale up your EC2 Fleet, increase its target capacity. The EC2 Fleet launches the additional Spot Instances according to the allocation strategy for the EC2 Fleet request. If the allocation strategy is lowest-price, the EC2 Fleet launches instances using the Spot Instance pool with the lowest price. If the allocation strategy is diversified, the EC2 Fleet distributes the instances across the Spot Instance pools. If the allocation strategy is capacity-optimized, EC2 Fleet launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching. To scale down your EC2 Fleet, decrease its target capacity. First, the EC2 Fleet cancels any open requests that exceed the new target capacity. You can request that the EC2 Fleet terminate Spot Instances until the size of the fleet no longer exceeds the new target capacity. If the allocation strategy is lowest-price, the EC2 Fleet terminates the instances with the highest price per unit. If the allocation strategy is capacity-optimized, the EC2 Fleet terminates the instances in the Spot Instance pools that have the least available Spot Instance capacity. If the allocation strategy is diversified, the EC2 Fleet terminates instances across the Spot Instance pools. Alternatively, you can request that the EC2 Fleet keep the fleet at its current size, but not replace any Spot Instances that are interrupted or that you terminate manually. If you are finished with your EC2 Fleet for now, but will use it again later, you can set the target capacity to 0.
delete_fleetsdeleteFleetId, TerminateInstances, regionDryRunDeletes the specified EC2 Fleet request. After you delete an EC2 Fleet request, it launches no new instances. You must also specify whether a deleted EC2 Fleet request should terminate its instances. If you choose to terminate the instances, the EC2 Fleet request enters the deleted_terminating state. Otherwise, it enters the deleted_running state, and the instances continue to run until they are interrupted or you terminate them manually. A deleted instant fleet with running instances is not supported. When you delete an instant fleet, Amazon EC2 automatically terminates all its instances. For fleets with more than 1000 instances, the deletion request might fail. If your fleet has more than 1000 instances, first terminate most of the instances manually, leaving 1000 or fewer. Then delete the fleet, and the remaining instances will be terminated automatically. Terminating an instance is permanent and irreversible. After you terminate an instance, you can no longer connect to it, and it can't be recovered. All attached Amazon EBS volumes that are configured to be deleted on termination are also permanently deleted and can't be recovered. All data stored on instance store volumes is permanently lost. For more information, see How instance termination works. Before you terminate an instance, ensure that you have backed up all data that you need to retain after the termination to persistent storage. Restrictions You can delete up to 25 fleets of type instant in a single request. You can delete up to 100 fleets of type maintain or request in a single request. You can delete up to 125 fleets in a single request, provided you do not exceed the quota for each fleet type, as specified above. If you exceed the specified number of fleets to delete, no fleets are deleted. For more information, see Delete an EC2 Fleet request and the instances in the fleet in the Amazon EC2 User Guide.

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
FleetIdarrayThe IDs of the EC2 Fleets. Constraints: In a single request, you can specify up to 25 instant fleet IDs and up to 100 maintain or request fleet IDs.
LaunchTemplateConfigsarrayThe configuration for the EC2 Fleet.
TargetCapacitySpecificationobjectThe number of units to request.
TerminateInstancesbooleanIndicates whether to terminate the associated instances when the EC2 Fleet is deleted. The default is to terminate the instances. To let the instances continue to run after the EC2 Fleet is deleted, specify no-terminate-instances. Supported only for fleets of type maintain and request. For instant fleets, you cannot specify NoTerminateInstances. A deleted instant fleet with running instances is not supported.
regionstringAWS region (default: us-east-1)
ClientTokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you do not specify a client token, a randomly generated token is used for the request to ensure idempotency. For more information, see Ensuring idempotency.
ContextstringReserved.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
ExcessCapacityTerminationPolicystringIndicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the EC2 Fleet. Supported only for fleets of type maintain.
FilterarrayThe filters. activity-status - The progress of the EC2 Fleet ( error | pending-fulfillment | pending-termination | fulfilled). excess-capacity-termination-policy - Indicates whether to terminate running instances if the target capacity is decreased below the current EC2 Fleet size (true | false). fleet-state - The state of the EC2 Fleet (submitted | active | deleted | failed | deleted-running | deleted-terminating | modifying). replace-unhealthy-instances - Indicates whether EC2 Fleet should replace unhealthy instances (true | false). type - The type of request (instant | request | maintain).
FleetIdarrayThe IDs of the EC2 Fleets. If a fleet is of type instant, you must specify the fleet ID, otherwise it does not appear in the response.
LaunchTemplateConfigarrayThe launch template and overrides.
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NextTokenstringThe token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.
OnDemandOptionsobjectDescribes the configuration of On-Demand Instances in an EC2 Fleet.
ReplaceUnhealthyInstancesbooleanIndicates whether EC2 Fleet should replace unhealthy Spot Instances. Supported only for fleets of type maintain. For more information, see EC2 Fleet health checks in the Amazon EC2 User Guide.
ReservedCapacityOptionsobjectDefines EC2 Fleet preferences for utilizing reserved capacity when DefaultTargetCapacityType is set to reserved-capacity. Supported only for fleets of type instant.
SpotOptionsobjectDescribes the configuration of Spot Instances in an EC2 Fleet.
TagSpecificationarrayThe key-value pair for tagging the EC2 Fleet request on creation. For more information, see Tag your resources. If the fleet type is instant, specify a resource type of fleet to tag the fleet, instance to tag the instances at launch, volume to tag the volumes at launch, or network-interface to tag the network interfaces at launch. If the fleet type is maintain or request, specify a resource type of fleet to tag the fleet. You cannot specify a resource type of instance, volume, or network-interface. To tag instances at launch, specify the tags in a launch template.
TargetCapacitySpecificationobjectThe size of the EC2 Fleet.
TerminateInstancesWithExpirationbooleanIndicates whether running instances should be terminated when the EC2 Fleet expires.
TypestringThe fleet type. The default value is maintain. maintain - The EC2 Fleet places an asynchronous request for your desired capacity, and continues to maintain your desired Spot capacity by replenishing interrupted Spot Instances. request - The EC2 Fleet places an asynchronous one-time request for your desired capacity, but does submit Spot requests in alternative capacity pools if Spot capacity is unavailable, and does not maintain Spot capacity if Spot Instances are interrupted. instant - The EC2 Fleet places a synchronous one-time request for your desired capacity, and returns errors for any instances that could not be launched. For more information, see EC2 Fleet request types in the Amazon EC2 User Guide.
ValidFromstring (date-time)The start date and time of the request, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the request immediately.
ValidUntilstring (date-time)The end date and time of the request, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new EC2 Fleet requests are placed or able to fulfill the request. If no value is specified, the request remains until you cancel it.

SELECT examples

Describes the specified EC2 Fleet or all of your EC2 Fleets. If a fleet is of type instant, you must specify the fleet ID in the request, otherwise the fleet does not appear in the response. For more information, see Describe your EC2 Fleet in the Amazon EC2 User Guide.

SELECT
activity_status,
client_token,
context,
create_time,
errors,
excess_capacity_termination_policy,
fleet_id,
fleet_state,
fulfilled_capacity,
fulfilled_on_demand_capacity,
instances,
launch_template_configs,
on_demand_options,
replace_unhealthy_instances,
reserved_capacity_options,
spot_options,
tags,
target_capacity_specification,
terminate_instances_with_expiration,
type,
valid_from,
valid_until
FROM aws.ec2.fleets
WHERE region = '{{ region }}' -- required
AND DryRun = '{{ DryRun }}'
AND MaxResults = '{{ MaxResults }}'
AND NextToken = '{{ NextToken }}'
AND FleetId = '{{ FleetId }}'
AND Filter = '{{ Filter }}'
;

INSERT examples

Creates an EC2 Fleet that contains the configuration information for On-Demand Instances and Spot Instances. Instances are launched immediately if there is available capacity. A single EC2 Fleet can include multiple launch specifications that vary by instance type, AMI, Availability Zone, or subnet. For more information, see EC2 Fleet in the Amazon EC2 User Guide.

INSERT INTO aws.ec2.fleets (
LaunchTemplateConfigs,
TargetCapacitySpecification,
region,
DryRun,
ClientToken,
SpotOptions,
OnDemandOptions,
ReservedCapacityOptions,
ExcessCapacityTerminationPolicy,
TerminateInstancesWithExpiration,
Type,
ValidFrom,
ValidUntil,
ReplaceUnhealthyInstances,
TagSpecification,
Context
)
SELECT
'{{ LaunchTemplateConfigs }}',
'{{ TargetCapacitySpecification }}',
'{{ region }}',
'{{ DryRun }}',
'{{ ClientToken }}',
'{{ SpotOptions }}',
'{{ OnDemandOptions }}',
'{{ ReservedCapacityOptions }}',
'{{ ExcessCapacityTerminationPolicy }}',
'{{ TerminateInstancesWithExpiration }}',
'{{ Type }}',
'{{ ValidFrom }}',
'{{ ValidUntil }}',
'{{ ReplaceUnhealthyInstances }}',
'{{ TagSpecification }}',
'{{ Context }}'
RETURNING
errors,
fleet_id,
instances
;

UPDATE examples

Modifies the specified EC2 Fleet. You can only modify an EC2 Fleet request of type maintain. While the EC2 Fleet is being modified, it is in the modifying state. To scale up your EC2 Fleet, increase its target capacity. The EC2 Fleet launches the additional Spot Instances according to the allocation strategy for the EC2 Fleet request. If the allocation strategy is lowest-price, the EC2 Fleet launches instances using the Spot Instance pool with the lowest price. If the allocation strategy is diversified, the EC2 Fleet distributes the instances across the Spot Instance pools. If the allocation strategy is capacity-optimized, EC2 Fleet launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching. To scale down your EC2 Fleet, decrease its target capacity. First, the EC2 Fleet cancels any open requests that exceed the new target capacity. You can request that the EC2 Fleet terminate Spot Instances until the size of the fleet no longer exceeds the new target capacity. If the allocation strategy is lowest-price, the EC2 Fleet terminates the instances with the highest price per unit. If the allocation strategy is capacity-optimized, the EC2 Fleet terminates the instances in the Spot Instance pools that have the least available Spot Instance capacity. If the allocation strategy is diversified, the EC2 Fleet terminates instances across the Spot Instance pools. Alternatively, you can request that the EC2 Fleet keep the fleet at its current size, but not replace any Spot Instances that are interrupted or that you terminate manually. If you are finished with your EC2 Fleet for now, but will use it again later, you can set the target capacity to 0.

UPDATE aws.ec2.fleets
SET
-- No updatable properties
WHERE
FleetId = '{{ FleetId }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}}
AND ExcessCapacityTerminationPolicy = '{{ ExcessCapacityTerminationPolicy}}'
AND LaunchTemplateConfig = '{{ LaunchTemplateConfig}}'
AND TargetCapacitySpecification = '{{ TargetCapacitySpecification}}'
AND Context = '{{ Context}}'
RETURNING
return;

DELETE examples

Deletes the specified EC2 Fleet request. After you delete an EC2 Fleet request, it launches no new instances. You must also specify whether a deleted EC2 Fleet request should terminate its instances. If you choose to terminate the instances, the EC2 Fleet request enters the deleted_terminating state. Otherwise, it enters the deleted_running state, and the instances continue to run until they are interrupted or you terminate them manually. A deleted instant fleet with running instances is not supported. When you delete an instant fleet, Amazon EC2 automatically terminates all its instances. For fleets with more than 1000 instances, the deletion request might fail. If your fleet has more than 1000 instances, first terminate most of the instances manually, leaving 1000 or fewer. Then delete the fleet, and the remaining instances will be terminated automatically. Terminating an instance is permanent and irreversible. After you terminate an instance, you can no longer connect to it, and it can't be recovered. All attached Amazon EBS volumes that are configured to be deleted on termination are also permanently deleted and can't be recovered. All data stored on instance store volumes is permanently lost. For more information, see How instance termination works. Before you terminate an instance, ensure that you have backed up all data that you need to retain after the termination to persistent storage. Restrictions You can delete up to 25 fleets of type instant in a single request. You can delete up to 100 fleets of type maintain or request in a single request. You can delete up to 125 fleets in a single request, provided you do not exceed the quota for each fleet type, as specified above. If you exceed the specified number of fleets to delete, no fleets are deleted. For more information, see Delete an EC2 Fleet request and the instances in the fleet in the Amazon EC2 User Guide.

DELETE FROM aws.ec2.fleets
WHERE FleetId = '{{ FleetId }}' --required
AND TerminateInstances = '{{ TerminateInstances }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
;