SpotFleetRequestArgs

data class SpotFleetRequestArgs(val allocationStrategy: Output<String>? = null, val context: Output<String>? = null, val excessCapacityTerminationPolicy: Output<String>? = null, val fleetType: Output<String>? = null, val iamFleetRole: Output<String>? = null, val instanceInterruptionBehaviour: Output<String>? = null, val instancePoolsToUseCount: Output<Int>? = null, val launchSpecifications: Output<List<SpotFleetRequestLaunchSpecificationArgs>>? = null, val launchTemplateConfigs: Output<List<SpotFleetRequestLaunchTemplateConfigArgs>>? = null, val loadBalancers: Output<List<String>>? = null, val onDemandAllocationStrategy: Output<String>? = null, val onDemandMaxTotalPrice: Output<String>? = null, val onDemandTargetCapacity: Output<Int>? = null, val replaceUnhealthyInstances: Output<Boolean>? = null, val spotMaintenanceStrategies: Output<SpotFleetRequestSpotMaintenanceStrategiesArgs>? = null, val spotPrice: Output<String>? = null, val tags: Output<Map<String, String>>? = null, val targetCapacity: Output<Int>? = null, val targetCapacityUnitType: Output<String>? = null, val targetGroupArns: Output<List<String>>? = null, val terminateInstancesOnDelete: Output<String>? = null, val terminateInstancesWithExpiration: Output<Boolean>? = null, val validFrom: Output<String>? = null, val validUntil: Output<String>? = null, val waitForFulfillment: Output<Boolean>? = null) : ConvertibleToJava<SpotFleetRequestArgs>

Provides an EC2 Spot Fleet Request resource. This allows a fleet of Spot instances to be requested on the Spot market.

Example Usage

Using launch specifications

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.SpotFleetRequest;
import com.pulumi.aws.ec2.SpotFleetRequestArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchSpecificationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var cheapCompute = new SpotFleetRequest("cheapCompute", SpotFleetRequestArgs.builder()
.iamFleetRole("arn:aws:iam::12345678:role/spot-fleet")
.spotPrice("0.03")
.allocationStrategy("diversified")
.targetCapacity(6)
.validUntil("2019-11-04T20:44:20Z")
.launchSpecifications(
SpotFleetRequestLaunchSpecificationArgs.builder()
.instanceType("m4.10xlarge")
.ami("ami-1234")
.spotPrice("2.793")
.placementTenancy("dedicated")
.iamInstanceProfileArn(aws_iam_instance_profile.example().arn())
.build(),
SpotFleetRequestLaunchSpecificationArgs.builder()
.instanceType("m4.4xlarge")
.ami("ami-5678")
.keyName("my-key")
.spotPrice("1.117")
.iamInstanceProfileArn(aws_iam_instance_profile.example().arn())
.availabilityZone("us-west-1a")
.subnetId("subnet-1234")
.weightedCapacity(35)
.rootBlockDevices(SpotFleetRequestLaunchSpecificationRootBlockDeviceArgs.builder()
.volumeSize("300")
.volumeType("gp2")
.build())
.tags(Map.of("Name", "spot-fleet-example"))
.build())
.build());
}
}

Using launch templates

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.LaunchTemplate;
import com.pulumi.aws.ec2.LaunchTemplateArgs;
import com.pulumi.aws.ec2.SpotFleetRequest;
import com.pulumi.aws.ec2.SpotFleetRequestArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchTemplateConfigArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchTemplateConfigLaunchTemplateSpecificationArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var fooLaunchTemplate = new LaunchTemplate("fooLaunchTemplate", LaunchTemplateArgs.builder()
.imageId("ami-516b9131")
.instanceType("m1.small")
.keyName("some-key")
.build());
var fooSpotFleetRequest = new SpotFleetRequest("fooSpotFleetRequest", SpotFleetRequestArgs.builder()
.iamFleetRole("arn:aws:iam::12345678:role/spot-fleet")
.spotPrice("0.005")
.targetCapacity(2)
.validUntil("2019-11-04T20:44:20Z")
.launchTemplateConfigs(SpotFleetRequestLaunchTemplateConfigArgs.builder()
.launchTemplateSpecification(SpotFleetRequestLaunchTemplateConfigLaunchTemplateSpecificationArgs.builder()
.id(fooLaunchTemplate.id())
.version(fooLaunchTemplate.latestVersion())
.build())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(aws_iam_policy_attachment.test-attach())
.build());
}
}

Using multiple launch specifications

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.SpotFleetRequest;
import com.pulumi.aws.ec2.SpotFleetRequestArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchSpecificationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var foo = new SpotFleetRequest("foo", SpotFleetRequestArgs.builder()
.iamFleetRole("arn:aws:iam::12345678:role/spot-fleet")
.launchSpecifications(
SpotFleetRequestLaunchSpecificationArgs.builder()
.ami("ami-d06a90b0")
.availabilityZone("us-west-2a")
.instanceType("m1.small")
.keyName("my-key")
.build(),
SpotFleetRequestLaunchSpecificationArgs.builder()
.ami("ami-d06a90b0")
.availabilityZone("us-west-2a")
.instanceType("m5.large")
.keyName("my-key")
.build())
.spotPrice("0.005")
.targetCapacity(2)
.validUntil("2019-11-04T20:44:20Z")
.build());
}
}

Using multiple launch configurations

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetSubnetIdsArgs;
import com.pulumi.aws.ec2.LaunchTemplate;
import com.pulumi.aws.ec2.LaunchTemplateArgs;
import com.pulumi.aws.ec2.SpotFleetRequest;
import com.pulumi.aws.ec2.SpotFleetRequestArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchTemplateConfigArgs;
import com.pulumi.aws.ec2.inputs.SpotFleetRequestLaunchTemplateConfigLaunchTemplateSpecificationArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = Ec2Functions.getSubnetIds(GetSubnetIdsArgs.builder()
.vpcId(var_.vpc_id())
.build());
var fooLaunchTemplate = new LaunchTemplate("fooLaunchTemplate", LaunchTemplateArgs.builder()
.imageId("ami-516b9131")
.instanceType("m1.small")
.keyName("some-key")
.build());
var fooSpotFleetRequest = new SpotFleetRequest("fooSpotFleetRequest", SpotFleetRequestArgs.builder()
.iamFleetRole("arn:aws:iam::12345678:role/spot-fleet")
.spotPrice("0.005")
.targetCapacity(2)
.validUntil("2019-11-04T20:44:20Z")
.launchTemplateConfigs(SpotFleetRequestLaunchTemplateConfigArgs.builder()
.launchTemplateSpecification(SpotFleetRequestLaunchTemplateConfigLaunchTemplateSpecificationArgs.builder()
.id(fooLaunchTemplate.id())
.version(fooLaunchTemplate.latestVersion())
.build())
.overrides(
SpotFleetRequestLaunchTemplateConfigOverrideArgs.builder()
.subnetId(data.aws_subnets().example().ids()[0])
.build(),
SpotFleetRequestLaunchTemplateConfigOverrideArgs.builder()
.subnetId(data.aws_subnets().example().ids()[1])
.build(),
SpotFleetRequestLaunchTemplateConfigOverrideArgs.builder()
.subnetId(data.aws_subnets().example().ids()[2])
.build())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(aws_iam_policy_attachment.test-attach())
.build());
}
}

Import

Spot Fleet Requests can be imported using id, e.g.,

$ pulumi import aws:ec2/spotFleetRequest:SpotFleetRequest fleet sfr-005e9ec8-5546-4c31-b317-31a62325411e

Constructors

Link copied to clipboard
constructor(allocationStrategy: Output<String>? = null, context: Output<String>? = null, excessCapacityTerminationPolicy: Output<String>? = null, fleetType: Output<String>? = null, iamFleetRole: Output<String>? = null, instanceInterruptionBehaviour: Output<String>? = null, instancePoolsToUseCount: Output<Int>? = null, launchSpecifications: Output<List<SpotFleetRequestLaunchSpecificationArgs>>? = null, launchTemplateConfigs: Output<List<SpotFleetRequestLaunchTemplateConfigArgs>>? = null, loadBalancers: Output<List<String>>? = null, onDemandAllocationStrategy: Output<String>? = null, onDemandMaxTotalPrice: Output<String>? = null, onDemandTargetCapacity: Output<Int>? = null, replaceUnhealthyInstances: Output<Boolean>? = null, spotMaintenanceStrategies: Output<SpotFleetRequestSpotMaintenanceStrategiesArgs>? = null, spotPrice: Output<String>? = null, tags: Output<Map<String, String>>? = null, targetCapacity: Output<Int>? = null, targetCapacityUnitType: Output<String>? = null, targetGroupArns: Output<List<String>>? = null, terminateInstancesOnDelete: Output<String>? = null, terminateInstancesWithExpiration: Output<Boolean>? = null, validFrom: Output<String>? = null, validUntil: Output<String>? = null, waitForFulfillment: Output<Boolean>? = null)

Properties

Link copied to clipboard
val allocationStrategy: Output<String>? = null

Indicates how to allocate the target capacity across the Spot pools specified by the Spot fleet request. Valid values: lowestPrice, diversified, capacityOptimized, capacityOptimizedPrioritized, and priceCapacityOptimized. The default is lowestPrice.

Link copied to clipboard
val context: Output<String>? = null

Reserved.

Link copied to clipboard

Indicates whether running Spot instances should be terminated if the target capacity of the Spot fleet request is decreased below the current size of the Spot fleet.

Link copied to clipboard
val fleetType: Output<String>? = null

The type of fleet request. Indicates whether the Spot Fleet only requests the target capacity or also attempts to maintain it. Default is maintain.

Link copied to clipboard
val iamFleetRole: Output<String>? = null

Grants the Spot fleet permission to terminate Spot instances on your behalf when you cancel its Spot fleet request using CancelSpotFleetRequests or when the Spot fleet request expires, if you set terminateInstancesWithExpiration.

Link copied to clipboard

Indicates whether a Spot instance stops or terminates when it is interrupted. Default is terminate.

Link copied to clipboard
val instancePoolsToUseCount: Output<Int>? = null

The number of Spot pools across which to allocate your target Spot capacity. Valid only when allocation_strategy is set to lowestPrice. Spot Fleet selects the cheapest Spot pools and evenly allocates your target Spot capacity across the number of Spot pools that you specify.

Link copied to clipboard

Used to define the launch configuration of the spot-fleet request. Can be specified multiple times to define different bids across different markets and instance types. Conflicts with launch_template_config. At least one of launch_specification or launch_template_config is required. Note: This takes in similar but not identical inputs as aws.ec2.Instance. There are limitations on what you can specify. See the list of officially supported inputs in the reference documentation. Any normal aws.ec2.Instance parameter that corresponds to those inputs may be used and it have a additional parameter iam_instance_profile_arn takes aws.iam.InstanceProfile attribute arn as input.

Link copied to clipboard

Launch template configuration block. See Launch Template Configs below for more details. Conflicts with launch_specification. At least one of launch_specification or launch_template_config is required.

Link copied to clipboard
val loadBalancers: Output<List<String>>? = null

A list of elastic load balancer names to add to the Spot fleet.

Link copied to clipboard
val onDemandAllocationStrategy: Output<String>? = null

The order of the launch template overrides to use in fulfilling On-Demand capacity. the possible values are: lowestPrice and prioritized. the default is lowestPrice.

Link copied to clipboard
val onDemandMaxTotalPrice: Output<String>? = null

The maximum amount per hour for On-Demand Instances that you're willing to pay. When the maximum amount you're willing to pay is reached, the fleet stops launching instances even if it hasn’t met the target capacity.

Link copied to clipboard
val onDemandTargetCapacity: Output<Int>? = null

The number of On-Demand units to request. If the request type is maintain, you can specify a target capacity of 0 and add capacity later.

Link copied to clipboard
val replaceUnhealthyInstances: Output<Boolean>? = null

Indicates whether Spot fleet should replace unhealthy instances. Default false.

Link copied to clipboard

Nested argument containing maintenance strategies for managing your Spot Instances that are at an elevated risk of being interrupted. Defined below.

Link copied to clipboard
val spotPrice: Output<String>? = null

The maximum bid price per unit hour.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

A map of tags to assign to the resource. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val targetCapacity: Output<Int>? = null

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

Link copied to clipboard
val targetCapacityUnitType: Output<String>? = null

The unit for the target capacity. This can only be done with instance_requirements defined

Link copied to clipboard
val targetGroupArns: Output<List<String>>? = null

A list of aws.alb.TargetGroup ARNs, for use with Application Load Balancing.

Link copied to clipboard
val terminateInstancesOnDelete: Output<String>? = null

Indicates whether running Spot instances should be terminated when the resource is deleted (and the Spot fleet request cancelled). If no value is specified, the value of the terminate_instances_with_expiration argument is used.

Link copied to clipboard

Indicates whether running Spot instances should be terminated when the Spot fleet request expires.

Link copied to clipboard
val validFrom: Output<String>? = null

The start date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the request immediately.

Link copied to clipboard
val validUntil: Output<String>? = null

The end date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ). At this point, no new Spot instance requests are placed or enabled to fulfill the request.

Link copied to clipboard
val waitForFulfillment: Output<Boolean>? = null

If set, this provider will wait for the Spot Request to be fulfilled, and will throw an error if the timeout of 10m is reached.

Functions

Link copied to clipboard
open override fun toJava(): SpotFleetRequestArgs