Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

CreateFleet

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.

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.

ClientToken

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

Type: String

Required: No

DryRun

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 is UnauthorizedOperation.

Type: Boolean

Required: No

ExcessCapacityTerminationPolicy

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.

Type: String

Valid Values: no-termination | termination

Required: No

LaunchTemplateConfigs.N

The configuration for the EC2 Fleet.

Type: Array of FleetLaunchTemplateConfigRequest objects

Array Members: Maximum number of 50 items.

Required: Yes

OnDemandOptions

The allocation strategy of On-Demand Instances in an EC2 Fleet.

Type: OnDemandOptionsRequest object

Required: No

ReplaceUnhealthyInstances

Indicates whether EC2 Fleet should replace unhealthy instances.

Type: Boolean

Required: No

SpotOptions

Describes the configuration of Spot Instances in an EC2 Fleet.

Type: SpotOptionsRequest object

Required: No

TagSpecification.N

The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType must be fleet, 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.

Type: Array of TagSpecification objects

Required: No

TargetCapacitySpecification

The TotalTargetCapacity, OnDemandTargetCapacity, SpotTargetCapacity, and DefaultCapacityType structure.

Type: TargetCapacitySpecificationRequest object

Required: Yes

TerminateInstancesWithExpiration

Indicates whether running instances should be terminated when the EC2 Fleet expires.

Type: Boolean

Required: No

Type

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

Type: String

Valid Values: request | maintain

Required: No

ValidFrom

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.

Type: Timestamp

Required: No

ValidUntil

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. The default end date is 7 days from the current date.

Type: Timestamp

Required: No

Response Elements

The following elements are returned by the service.

fleetId

The ID of the EC2 Fleet.

Type: String

requestId

The ID of the request.

Type: String

Errors

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

Example

Example

This example creates an EC2 Fleet with a target capacity of 100 instances, of which 70 are specified as On-Demand Instances, and the balance are Spot Instances.

Sample Request

https://ec2.amazonaws.com/?Action=CreateFleet &FleetRequestConfig.IamFleetRole=arn:aws:iam::123456789011:role/fleet-role &FleetRequestConfig.LaunchTemplateName=ABC123 &FleetRequestConfig.TotalTargetCapacity=100 &FleetRequestConfig.OnDemandTargetCapacity=70 &FleetRequestConfig.InstanceTypes=c3.large, c4.large, c5.large &FleetRequestConfig.DefaultTargetCapacity=Spot &AUTHPARAMS

Sample Response

<CreateFleetResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>60262cc5-2bd4-4c8d-98ed-example</requestId> <fleetId>fleet-123f8fc2-cb31-425e-abcd-example2710</fleetId> </CreateFleetResponse>

See Also

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