Launches an EC2 Fleet.
You can create a single EC2 Fleet that includes multiple launch specifications that vary by instance type, AMI, Availability Zone, or subnet.
For more information, see Launching an EC2 Fleet in the Amazon Elastic Compute Cloud User Guide .
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
create-fleet
[--dry-run | --no-dry-run]
[--client-token <value>]
[--spot-options <value>]
[--on-demand-options <value>]
[--excess-capacity-termination-policy <value>]
--launch-template-configs <value>
--target-capacity-specification <value>
[--terminate-instances-with-expiration | --no-terminate-instances-with-expiration]
[--type <value>]
[--valid-from <value>]
[--valid-until <value>]
[--replace-unhealthy-instances | --no-replace-unhealthy-instances]
[--tag-specifications <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--cli-auto-prompt <value>]
--dry-run
| --no-dry-run
(boolean)
Checks 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 isUnauthorizedOperation
.
--client-token
(string)
Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring Idempotency .
--spot-options
(structure)
Describes the configuration of Spot Instances in an EC2 Fleet.
AllocationStrategy -> (string)
Indicates how to allocate the target Spot Instance capacity across the Spot Instance pools specified by the EC2 Fleet.
If the allocation strategy is
lowest-price
, EC2 Fleet launches instances from the Spot Instance pools with the lowest price. This is the default allocation strategy.If the allocation strategy is
diversified
, EC2 Fleet launches instances from all of the Spot Instance pools that you specify.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.InstanceInterruptionBehavior -> (string)
The behavior when a Spot Instance is interrupted. The default is
terminate
.InstancePoolsToUseCount -> (integer)
The number of Spot pools across which to allocate your target Spot capacity. Valid only when Spot AllocationStrategy is set to
lowest-price
. EC2 Fleet selects the cheapest Spot pools and evenly allocates your target Spot capacity across the number of Spot pools that you specify.SingleInstanceType -> (boolean)
Indicates that the fleet uses a single instance type to launch all Spot Instances in the fleet. Supported only for fleets of type
instant
.SingleAvailabilityZone -> (boolean)
Indicates that the fleet launches all Spot Instances into a single Availability Zone. Supported only for fleets of type
instant
.MinTargetCapacity -> (integer)
The minimum target capacity for Spot Instances in the fleet. If the minimum target capacity is not reached, the fleet launches no instances.
MaxTotalPrice -> (string)
The maximum amount per hour for Spot Instances that you’re willing to pay.
Shorthand Syntax:
AllocationStrategy=string,InstanceInterruptionBehavior=string,InstancePoolsToUseCount=integer,SingleInstanceType=boolean,SingleAvailabilityZone=boolean,MinTargetCapacity=integer,MaxTotalPrice=string
JSON Syntax:
{
"AllocationStrategy": "lowest-price"|"diversified"|"capacity-optimized",
"InstanceInterruptionBehavior": "hibernate"|"stop"|"terminate",
"InstancePoolsToUseCount": integer,
"SingleInstanceType": true|false,
"SingleAvailabilityZone": true|false,
"MinTargetCapacity": integer,
"MaxTotalPrice": "string"
}
--on-demand-options
(structure)
Describes the configuration of On-Demand Instances in an EC2 Fleet.
AllocationStrategy -> (string)
The order of the launch template overrides to use in fulfilling On-Demand capacity. If you specify
lowest-price
, EC2 Fleet uses price to determine the order, launching the lowest price first. If you specifyprioritized
, EC2 Fleet uses the priority that you assigned to each launch template override, launching the highest priority first. If you do not specify a value, EC2 Fleet defaults tolowest-price
.CapacityReservationOptions -> (structure)
The strategy for using unused Capacity Reservations for fulfilling On-Demand capacity. Supported only for fleets of type
instant
.UsageStrategy -> (string)
Indicates whether to use unused Capacity Reservations for fulfilling On-Demand capacity.
If you specify
use-capacity-reservations-first
, the fleet uses unused Capacity Reservations to fulfill On-Demand capacity up to the target On-Demand capacity. If multiple instance pools have unused Capacity Reservations, the On-Demand allocation strategy (lowest-price
orprioritized
) is applied. If the number of unused Capacity Reservations is less than the On-Demand target capacity, the remaining On-Demand target capacity is launched according to the On-Demand allocation strategy (lowest-price
orprioritized
).If you do not specify a value, the fleet fulfils the On-Demand capacity according to the chosen On-Demand allocation strategy.
SingleInstanceType -> (boolean)
Indicates that the fleet uses a single instance type to launch all On-Demand Instances in the fleet. Supported only for fleets of type
instant
.SingleAvailabilityZone -> (boolean)
Indicates that the fleet launches all On-Demand Instances into a single Availability Zone. Supported only for fleets of type
instant
.MinTargetCapacity -> (integer)
The minimum target capacity for On-Demand Instances in the fleet. If the minimum target capacity is not reached, the fleet launches no instances.
MaxTotalPrice -> (string)
The maximum amount per hour for On-Demand Instances that you’re willing to pay.
Shorthand Syntax:
AllocationStrategy=string,CapacityReservationOptions={UsageStrategy=string},SingleInstanceType=boolean,SingleAvailabilityZone=boolean,MinTargetCapacity=integer,MaxTotalPrice=string
JSON Syntax:
{
"AllocationStrategy": "lowest-price"|"prioritized",
"CapacityReservationOptions": {
"UsageStrategy": "use-capacity-reservations-first"
},
"SingleInstanceType": true|false,
"SingleAvailabilityZone": true|false,
"MinTargetCapacity": integer,
"MaxTotalPrice": "string"
}
--excess-capacity-termination-policy
(string)
Indicates 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.
Possible values:
no-termination
termination
--launch-template-configs
(list)
The configuration for the EC2 Fleet.
(structure)
Describes a launch template and overrides.
LaunchTemplateSpecification -> (structure)
The launch template to use. You must specify either the launch template ID or launch template name in the request.
LaunchTemplateId -> (string)
The ID of the launch template. If you specify the template ID, you can’t specify the template name.
LaunchTemplateName -> (string)
The name of the launch template. If you specify the template name, you can’t specify the template ID.
Version -> (string)
The launch template version number,
$Latest
, or$Default
. You must specify a value, otherwise the request fails.If the value is
$Latest
, Amazon EC2 uses the latest version of the launch template.If the value is
$Default
, Amazon EC2 uses the default version of the launch template.Overrides -> (list)
Any parameters that you specify override the same parameters in the launch template.
(structure)
Describes overrides for a launch template.
InstanceType -> (string)
The instance type.
MaxPrice -> (string)
The maximum price per unit hour that you are willing to pay for a Spot Instance.
SubnetId -> (string)
The IDs of the subnets in which to launch the instances. Separate multiple subnet IDs using commas (for example,
subnet-1234abcdeexample1, subnet-0987cdef6example2
). A request of typeinstant
can have only one subnet ID.AvailabilityZone -> (string)
The Availability Zone in which to launch the instances.
WeightedCapacity -> (double)
The number of units provided by the specified instance type.
Priority -> (double)
The priority for the launch template override. If AllocationStrategy is set to
prioritized
, EC2 Fleet uses priority to determine which launch template override to use first in fulfilling On-Demand capacity. The highest priority is launched first. Valid values are whole numbers starting at0
. The lower the number, the higher the priority. If no number is set, the launch template override has the lowest priority.Placement -> (structure)
The location where the instance launched, if applicable.
AvailabilityZone -> (string)
The Availability Zone of the instance.
If not specified, an Availability Zone will be automatically chosen for you based on the load balancing criteria for the Region.
This parameter is not supported by CreateFleet .
Affinity -> (string)
The affinity setting for the instance on the Dedicated Host. This parameter is not supported for the ImportInstance command.
This parameter is not supported by CreateFleet .
GroupName -> (string)
The name of the placement group the instance is in.
PartitionNumber -> (integer)
The number of the partition the instance is in. Valid only if the placement group strategy is set to
partition
.This parameter is not supported by CreateFleet .
HostId -> (string)
The ID of the Dedicated Host on which the instance resides. This parameter is not supported for the ImportInstance command.
This parameter is not supported by CreateFleet .
Tenancy -> (string)
The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of
dedicated
runs on single-tenant hardware. Thehost
tenancy is not supported for the ImportInstance command.This parameter is not supported by CreateFleet .
SpreadDomain -> (string)
Reserved for future use.
This parameter is not supported by CreateFleet .
HostResourceGroupArn -> (string)
The ARN of the host resource group in which to launch the instances. If you specify a host resource group ARN, omit the Tenancy parameter or set it to
host
.This parameter is not supported by CreateFleet .
JSON Syntax:
[
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "string",
"LaunchTemplateName": "string",
"Version": "string"
},
"Overrides": [
{
"InstanceType": "t1.micro"|"t2.nano"|"t2.micro"|"t2.small"|"t2.medium"|"t2.large"|"t2.xlarge"|"t2.2xlarge"|"t3.nano"|"t3.micro"|"t3.small"|"t3.medium"|"t3.large"|"t3.xlarge"|"t3.2xlarge"|"t3a.nano"|"t3a.micro"|"t3a.small"|"t3a.medium"|"t3a.large"|"t3a.xlarge"|"t3a.2xlarge"|"m1.small"|"m1.medium"|"m1.large"|"m1.xlarge"|"m3.medium"|"m3.large"|"m3.xlarge"|"m3.2xlarge"|"m4.large"|"m4.xlarge"|"m4.2xlarge"|"m4.4xlarge"|"m4.10xlarge"|"m4.16xlarge"|"m2.xlarge"|"m2.2xlarge"|"m2.4xlarge"|"cr1.8xlarge"|"r3.large"|"r3.xlarge"|"r3.2xlarge"|"r3.4xlarge"|"r3.8xlarge"|"r4.large"|"r4.xlarge"|"r4.2xlarge"|"r4.4xlarge"|"r4.8xlarge"|"r4.16xlarge"|"r5.large"|"r5.xlarge"|"r5.2xlarge"|"r5.4xlarge"|"r5.8xlarge"|"r5.12xlarge"|"r5.16xlarge"|"r5.24xlarge"|"r5.metal"|"r5a.large"|"r5a.xlarge"|"r5a.2xlarge"|"r5a.4xlarge"|"r5a.8xlarge"|"r5a.12xlarge"|"r5a.16xlarge"|"r5a.24xlarge"|"r5d.large"|"r5d.xlarge"|"r5d.2xlarge"|"r5d.4xlarge"|"r5d.8xlarge"|"r5d.12xlarge"|"r5d.16xlarge"|"r5d.24xlarge"|"r5d.metal"|"r5ad.large"|"r5ad.xlarge"|"r5ad.2xlarge"|"r5ad.4xlarge"|"r5ad.8xlarge"|"r5ad.12xlarge"|"r5ad.16xlarge"|"r5ad.24xlarge"|"r6g.metal"|"r6g.medium"|"r6g.large"|"r6g.xlarge"|"r6g.2xlarge"|"r6g.4xlarge"|"r6g.8xlarge"|"r6g.12xlarge"|"r6g.16xlarge"|"x1.16xlarge"|"x1.32xlarge"|"x1e.xlarge"|"x1e.2xlarge"|"x1e.4xlarge"|"x1e.8xlarge"|"x1e.16xlarge"|"x1e.32xlarge"|"i2.xlarge"|"i2.2xlarge"|"i2.4xlarge"|"i2.8xlarge"|"i3.large"|"i3.xlarge"|"i3.2xlarge"|"i3.4xlarge"|"i3.8xlarge"|"i3.16xlarge"|"i3.metal"|"i3en.large"|"i3en.xlarge"|"i3en.2xlarge"|"i3en.3xlarge"|"i3en.6xlarge"|"i3en.12xlarge"|"i3en.24xlarge"|"i3en.metal"|"hi1.4xlarge"|"hs1.8xlarge"|"c1.medium"|"c1.xlarge"|"c3.large"|"c3.xlarge"|"c3.2xlarge"|"c3.4xlarge"|"c3.8xlarge"|"c4.large"|"c4.xlarge"|"c4.2xlarge"|"c4.4xlarge"|"c4.8xlarge"|"c5.large"|"c5.xlarge"|"c5.2xlarge"|"c5.4xlarge"|"c5.9xlarge"|"c5.12xlarge"|"c5.18xlarge"|"c5.24xlarge"|"c5.metal"|"c5a.large"|"c5a.xlarge"|"c5a.2xlarge"|"c5a.4xlarge"|"c5a.8xlarge"|"c5a.12xlarge"|"c5a.16xlarge"|"c5a.24xlarge"|"c5d.large"|"c5d.xlarge"|"c5d.2xlarge"|"c5d.4xlarge"|"c5d.9xlarge"|"c5d.12xlarge"|"c5d.18xlarge"|"c5d.24xlarge"|"c5d.metal"|"c5n.large"|"c5n.xlarge"|"c5n.2xlarge"|"c5n.4xlarge"|"c5n.9xlarge"|"c5n.18xlarge"|"c6g.metal"|"c6g.medium"|"c6g.large"|"c6g.xlarge"|"c6g.2xlarge"|"c6g.4xlarge"|"c6g.8xlarge"|"c6g.12xlarge"|"c6g.16xlarge"|"cc1.4xlarge"|"cc2.8xlarge"|"g2.2xlarge"|"g2.8xlarge"|"g3.4xlarge"|"g3.8xlarge"|"g3.16xlarge"|"g3s.xlarge"|"g4dn.xlarge"|"g4dn.2xlarge"|"g4dn.4xlarge"|"g4dn.8xlarge"|"g4dn.12xlarge"|"g4dn.16xlarge"|"g4dn.metal"|"cg1.4xlarge"|"p2.xlarge"|"p2.8xlarge"|"p2.16xlarge"|"p3.2xlarge"|"p3.8xlarge"|"p3.16xlarge"|"p3dn.24xlarge"|"d2.xlarge"|"d2.2xlarge"|"d2.4xlarge"|"d2.8xlarge"|"f1.2xlarge"|"f1.4xlarge"|"f1.16xlarge"|"m5.large"|"m5.xlarge"|"m5.2xlarge"|"m5.4xlarge"|"m5.8xlarge"|"m5.12xlarge"|"m5.16xlarge"|"m5.24xlarge"|"m5.metal"|"m5a.large"|"m5a.xlarge"|"m5a.2xlarge"|"m5a.4xlarge"|"m5a.8xlarge"|"m5a.12xlarge"|"m5a.16xlarge"|"m5a.24xlarge"|"m5d.large"|"m5d.xlarge"|"m5d.2xlarge"|"m5d.4xlarge"|"m5d.8xlarge"|"m5d.12xlarge"|"m5d.16xlarge"|"m5d.24xlarge"|"m5d.metal"|"m5ad.large"|"m5ad.xlarge"|"m5ad.2xlarge"|"m5ad.4xlarge"|"m5ad.8xlarge"|"m5ad.12xlarge"|"m5ad.16xlarge"|"m5ad.24xlarge"|"h1.2xlarge"|"h1.4xlarge"|"h1.8xlarge"|"h1.16xlarge"|"z1d.large"|"z1d.xlarge"|"z1d.2xlarge"|"z1d.3xlarge"|"z1d.6xlarge"|"z1d.12xlarge"|"z1d.metal"|"u-6tb1.metal"|"u-9tb1.metal"|"u-12tb1.metal"|"u-18tb1.metal"|"u-24tb1.metal"|"a1.medium"|"a1.large"|"a1.xlarge"|"a1.2xlarge"|"a1.4xlarge"|"a1.metal"|"m5dn.large"|"m5dn.xlarge"|"m5dn.2xlarge"|"m5dn.4xlarge"|"m5dn.8xlarge"|"m5dn.12xlarge"|"m5dn.16xlarge"|"m5dn.24xlarge"|"m5n.large"|"m5n.xlarge"|"m5n.2xlarge"|"m5n.4xlarge"|"m5n.8xlarge"|"m5n.12xlarge"|"m5n.16xlarge"|"m5n.24xlarge"|"r5dn.large"|"r5dn.xlarge"|"r5dn.2xlarge"|"r5dn.4xlarge"|"r5dn.8xlarge"|"r5dn.12xlarge"|"r5dn.16xlarge"|"r5dn.24xlarge"|"r5n.large"|"r5n.xlarge"|"r5n.2xlarge"|"r5n.4xlarge"|"r5n.8xlarge"|"r5n.12xlarge"|"r5n.16xlarge"|"r5n.24xlarge"|"inf1.xlarge"|"inf1.2xlarge"|"inf1.6xlarge"|"inf1.24xlarge"|"m6g.metal"|"m6g.medium"|"m6g.large"|"m6g.xlarge"|"m6g.2xlarge"|"m6g.4xlarge"|"m6g.8xlarge"|"m6g.12xlarge"|"m6g.16xlarge",
"MaxPrice": "string",
"SubnetId": "string",
"AvailabilityZone": "string",
"WeightedCapacity": double,
"Priority": double,
"Placement": {
"AvailabilityZone": "string",
"Affinity": "string",
"GroupName": "string",
"PartitionNumber": integer,
"HostId": "string",
"Tenancy": "default"|"dedicated"|"host",
"SpreadDomain": "string",
"HostResourceGroupArn": "string"
}
}
...
]
}
...
]
--target-capacity-specification
(structure)
The number of units to request.
TotalTargetCapacity -> (integer)
The number of units to request, filled using
DefaultTargetCapacityType
.OnDemandTargetCapacity -> (integer)
The number of On-Demand units to request.
SpotTargetCapacity -> (integer)
The number of Spot units to request.
DefaultTargetCapacityType -> (string)
The default
TotalTargetCapacity
, which is eitherSpot
orOn-Demand
.
Shorthand Syntax:
TotalTargetCapacity=integer,OnDemandTargetCapacity=integer,SpotTargetCapacity=integer,DefaultTargetCapacityType=string
JSON Syntax:
{
"TotalTargetCapacity": integer,
"OnDemandTargetCapacity": integer,
"SpotTargetCapacity": integer,
"DefaultTargetCapacityType": "spot"|"on-demand"
}
--terminate-instances-with-expiration
| --no-terminate-instances-with-expiration
(boolean)
Indicates whether running instances should be terminated when the EC2 Fleet expires.
--type
(string)
The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired capacity, and maintains it by replenishing interrupted Spot Instances (
maintain
). A value ofinstant
places a synchronous one-time request, and returns errors for any instances that could not be launched. A value ofrequest
places an asynchronous one-time request without maintaining capacity or submitting requests in alternative capacity pools if capacity is unavailable. For more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide .Possible values:
request
maintain
instant
--valid-from
(timestamp)
The start date and time of the request, in UTC format (for example, YYYY -MM -DD T*HH* :MM :SS Z). The default is to start fulfilling the request immediately.
--valid-until
(timestamp)
The end date and time of the request, in UTC format (for example, YYYY -MM -DD T*HH* :MM :SS Z). 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.
--replace-unhealthy-instances
| --no-replace-unhealthy-instances
(boolean)
Indicates whether EC2 Fleet should replace unhealthy instances.
--tag-specifications
(list)
The key-value pair for tagging the EC2 Fleet request on creation. The value for
ResourceType
must befleet
, otherwise the fleet request fails. To tag instances at launch, specify the tags in the launch template . For information about tagging after launch, see Tagging Your Resources .(structure)
The tags to apply to a resource when the resource is being created.
ResourceType -> (string)
The type of resource to tag. Currently, the resource types that support tagging on creation are:
capacity-reservation
|client-vpn-endpoint
|dedicated-host
|dhcp-options
|export-image-task
|export-instance-task
|fleet
|fpga-image
|host-reservation
|import-image-task
|import-snapshot-task
|instance
|internet-gateway
|ipv4pool-ec2
|ipv6pool-ec2
|key-pair
|launch-template
|placement-group
|prefix-list
|natgateway
|network-acl
|security-group
|spot-fleet-request
|spot-instances-request
|snapshot
|subnet
|traffic-mirror-filter
|traffic-mirror-session
|traffic-mirror-target
|transit-gateway
|transit-gateway-attachment
|transit-gateway-route-table
|volume
|vpc
|vpc-endpoint
(for interface and gateway endpoints) |vpc-endpoint-service
(for AWS PrivateLink) |vpc-flow-log
.To tag a resource after it has been created, see CreateTags .
Tags -> (list)
The tags to apply to the resource.
(structure)
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 255 Unicode characters.
Shorthand Syntax:
ResourceType=string,Tags=[{Key=string,Value=string},{Key=string,Value=string}] ...
JSON Syntax:
[
{
"ResourceType": "client-vpn-endpoint"|"customer-gateway"|"dedicated-host"|"dhcp-options"|"elastic-ip"|"elastic-gpu"|"export-image-task"|"export-instance-task"|"fleet"|"fpga-image"|"host-reservation"|"image"|"import-image-task"|"import-snapshot-task"|"instance"|"internet-gateway"|"key-pair"|"launch-template"|"local-gateway-route-table-vpc-association"|"natgateway"|"network-acl"|"network-interface"|"placement-group"|"reserved-instances"|"route-table"|"security-group"|"snapshot"|"spot-fleet-request"|"spot-instances-request"|"subnet"|"traffic-mirror-filter"|"traffic-mirror-session"|"traffic-mirror-target"|"transit-gateway"|"transit-gateway-attachment"|"transit-gateway-multicast-domain"|"transit-gateway-route-table"|"volume"|"vpc"|"vpc-peering-connection"|"vpn-connection"|"vpn-gateway"|"vpc-flow-log",
"Tags": [
{
"Key": "string",
"Value": "string"
}
...
]
}
...
]
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--cli-auto-prompt
(boolean)
Automatically prompt for CLI input parameters.
See ‘aws help’ for descriptions of global parameters.
To create an EC2 Fleet that launches Spot Instances as the default purchasing model
This example creates an EC2 Fleet using the minimum parameters required to launch a fleet: a launch template, target capacity, and default purchasing model. The launch template is identified by its launch template ID and version number. The target capacity for the fleet is 2 instances, and the default purchasing model is spot
, which results in the fleet launching 2 Spot Instances.
When you create an EC2 Fleet, use a JSON file to specify information about the instances to launch.
Command:
aws ec2 create-fleet --cli-input-json file://file_name.json
Output:
{
"FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE"
}
Where file_name.json contains the following:
{
"LaunchTemplateConfigs": [
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0e8c754449b27161c",
"Version": "1"
}
}
],
"TargetCapacitySpecification": {
"TotalTargetCapacity": 2,
"DefaultTargetCapacityType": "spot"
}
}
To create an EC2 Fleet that launches On-Demand Instances as the default purchasing model
This example creates an EC2 Fleet using the minimum parameters required to launch a fleet: a launch template, target capacity, and default purchasing model. The launch template is identified by its launch template ID and version number. The target capacity for the fleet is 2 instances, and the default purchasing model is on-demand
, which results in the fleet launching 2 On-Demand Instances.
When you create an EC2 Fleet, use a JSON file to specify information about the instances to launch.
Command:
aws ec2 create-fleet --cli-input-json file://file_name.json
Output:
{
"FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE"
}
Where file_name.json contains the following:
{
"LaunchTemplateConfigs": [
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0e8c754449b27161c",
"Version": "1"
}
}
],
"TargetCapacitySpecification": {
"TotalTargetCapacity": 2,
"DefaultTargetCapacityType": "on-demand"
}
}
To create an EC2 Fleet that launches On-Demand Instances as the primary capacity
This example creates an EC2 Fleet that specifies the total target capacity of 2 instances for the fleet, and a target capacity of 1 On-Demand Instance. The default purchasing model is spot
. The fleet launches 1 On-Demand Instance as specified, but needs to launch one more instance to fulfil the total target capacity. The purchasing model for the difference is calculated as TotalTargetCapacity
- OnDemandTargetCapacity
= DefaultTargetCapacityType
, which results in the fleet launching 1 Spot Instance.
When you create an EC2 Fleet, use a JSON file to specify information about the instances to launch.
Command:
aws ec2 create-fleet --cli-input-json file://file_name.json
Output:
{
"FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE"
}
Where file_name.json contains the following:
{
"LaunchTemplateConfigs": [
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0e8c754449b27161c",
"Version": "1"
}
}
],
"TargetCapacitySpecification": {
"TotalTargetCapacity": 2,
"OnDemandTargetCapacity":1,
"DefaultTargetCapacityType": "spot"
}
}
To create an EC2 Fleet that launches Spot Instances using the lowest-price allocation strategy
If the allocation strategy for Spot Instances is not specified, the default allocation strategy, which is lowest-price
, is used. This example creates an EC2 Fleet using the lowest-price
allocation strategy. The three launch specifications, which override the launch template, have different instance types but the same weighted capacity and subnet. The total target capacity is 2 instances and the default purchasing model is spot
. The EC2 Fleet launches 2 Spot Instances using the instance type of the launch specification with the lowest price.
When you create an EC2 Fleet, use a JSON file to specify information about the instances to launch.
Command:
aws ec2 create-fleet --cli-input-json file://file_name.json
Output:
{
"FleetId": "fleet-12a34b55-67cd-8ef9-ba9b-9208dEXAMPLE"
}
Where file_name.json contains the following:
{
"LaunchTemplateConfigs": [
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0e8c754449b27161c",
"Version": "1"
}
"Overrides": [
{
"InstanceType": "c4.large",
"WeightedCapacity": 1,
"SubnetId": "subnet-a4f6c5d3"
},
{
"InstanceType": "c3.large",
"WeightedCapacity": 1,
"SubnetId": "subnet-a4f6c5d3"
},
{
"InstanceType": "c5.large",
"WeightedCapacity": 1,
"SubnetId": "subnet-a4f6c5d3"
}
]
}
],
"TargetCapacitySpecification": {
"TotalTargetCapacity": 2,
"DefaultTargetCapacityType": "spot"
}
}
FleetId -> (string)
The ID of the EC2 Fleet.
Errors -> (list)
Information about the instances that could not be launched by the fleet. Valid only when Type is set to
instant
.(structure)
Describes the instances that could not be launched by the fleet.
LaunchTemplateAndOverrides -> (structure)
The launch templates and overrides that were used for launching the instances. The values that you specify in the Overrides replace the values in the launch template.
LaunchTemplateSpecification -> (structure)
The launch template.
LaunchTemplateId -> (string)
The ID of the launch template. If you specify the template ID, you can’t specify the template name.
LaunchTemplateName -> (string)
The name of the launch template. If you specify the template name, you can’t specify the template ID.
Version -> (string)
The launch template version number,
$Latest
, or$Default
. You must specify a value, otherwise the request fails.If the value is
$Latest
, Amazon EC2 uses the latest version of the launch template.If the value is
$Default
, Amazon EC2 uses the default version of the launch template.Overrides -> (structure)
Any parameters that you specify override the same parameters in the launch template.
InstanceType -> (string)
The instance type.
MaxPrice -> (string)
The maximum price per unit hour that you are willing to pay for a Spot Instance.
SubnetId -> (string)
The ID of the subnet in which to launch the instances.
AvailabilityZone -> (string)
The Availability Zone in which to launch the instances.
WeightedCapacity -> (double)
The number of units provided by the specified instance type.
Priority -> (double)
The priority for the launch template override. If AllocationStrategy is set to
prioritized
, EC2 Fleet uses priority to determine which launch template override to use first in fulfilling On-Demand capacity. The highest priority is launched first. Valid values are whole numbers starting at0
. The lower the number, the higher the priority. If no number is set, the override has the lowest priority.Placement -> (structure)
The location where the instance launched, if applicable.
GroupName -> (string)
The name of the placement group that the instance is in.
Lifecycle -> (string)
Indicates if the instance that could not be launched was a Spot Instance or On-Demand Instance.
ErrorCode -> (string)
The error code that indicates why the instance could not be launched. For more information about error codes, see Error Codes .
ErrorMessage -> (string)
The error message that describes why the instance could not be launched. For more information about error messages, see Error Codes .
Instances -> (list)
Information about the instances that were launched by the fleet. Valid only when Type is set to
instant
.(structure)
Describes the instances that were launched by the fleet.
LaunchTemplateAndOverrides -> (structure)
The launch templates and overrides that were used for launching the instances. The values that you specify in the Overrides replace the values in the launch template.
LaunchTemplateSpecification -> (structure)
The launch template.
LaunchTemplateId -> (string)
The ID of the launch template. If you specify the template ID, you can’t specify the template name.
LaunchTemplateName -> (string)
The name of the launch template. If you specify the template name, you can’t specify the template ID.
Version -> (string)
The launch template version number,
$Latest
, or$Default
. You must specify a value, otherwise the request fails.If the value is
$Latest
, Amazon EC2 uses the latest version of the launch template.If the value is
$Default
, Amazon EC2 uses the default version of the launch template.Overrides -> (structure)
Any parameters that you specify override the same parameters in the launch template.
InstanceType -> (string)
The instance type.
MaxPrice -> (string)
The maximum price per unit hour that you are willing to pay for a Spot Instance.
SubnetId -> (string)
The ID of the subnet in which to launch the instances.
AvailabilityZone -> (string)
The Availability Zone in which to launch the instances.
WeightedCapacity -> (double)
The number of units provided by the specified instance type.
Priority -> (double)
The priority for the launch template override. If AllocationStrategy is set to
prioritized
, EC2 Fleet uses priority to determine which launch template override to use first in fulfilling On-Demand capacity. The highest priority is launched first. Valid values are whole numbers starting at0
. The lower the number, the higher the priority. If no number is set, the override has the lowest priority.Placement -> (structure)
The location where the instance launched, if applicable.
GroupName -> (string)
The name of the placement group that the instance is in.
Lifecycle -> (string)
Indicates if the instance that was launched is a Spot Instance or On-Demand Instance.
InstanceIds -> (list)
The IDs of the instances.
(string)
InstanceType -> (string)
The instance type.
Platform -> (string)
The value is
Windows
for Windows instances. Otherwise, the value is blank.