Class CfnSpotFleet
- All Implemented Interfaces:
IInspectable,ISpotFleetRef,IEnvironmentAware,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
The Spot Fleet request specifies the total target capacity and the On-Demand target capacity. Amazon EC2 calculates the difference between the total capacity and On-Demand capacity, and launches the difference as Spot capacity.
You can submit a single request that includes multiple launch specifications that vary by instance type, AMI, Availability Zone, or subnet.
By default, the Spot Fleet requests Spot Instances in the Spot Instance pool where the price per unit is the lowest. Each launch specification can include its own instance weighting that reflects the value of the instance type to your application workload.
Alternatively, you can specify that the Spot Fleet distribute the target capacity across the Spot pools included in its launch specifications. By ensuring that the Spot Instances in your Spot Fleet are in different Spot pools, you can improve the availability of your fleet.
You can specify tags for the Spot Fleet request and instances launched by the fleet. You cannot tag other resource types in a Spot Fleet request because only the spot-fleet-request and instance resource types are supported.
For more information, see Spot Fleet in the Amazon EC2 User Guide .
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;
CfnSpotFleet cfnSpotFleet = CfnSpotFleet.Builder.create(this, "MyCfnSpotFleet")
.spotFleetRequestConfigData(SpotFleetRequestConfigDataProperty.builder()
.iamFleetRole("iamFleetRole")
.targetCapacity(123)
// the properties below are optional
.allocationStrategy("allocationStrategy")
.context("context")
.excessCapacityTerminationPolicy("excessCapacityTerminationPolicy")
.instanceInterruptionBehavior("instanceInterruptionBehavior")
.instancePoolsToUseCount(123)
.launchSpecifications(List.of(SpotFleetLaunchSpecificationProperty.builder()
.imageId("imageId")
// the properties below are optional
.blockDeviceMappings(List.of(BlockDeviceMappingProperty.builder()
.deviceName("deviceName")
// the properties below are optional
.ebs(EbsBlockDeviceProperty.builder()
.deleteOnTermination(false)
.encrypted(false)
.iops(123)
.snapshotId("snapshotId")
.volumeSize(123)
.volumeType("volumeType")
.build())
.noDevice("noDevice")
.virtualName("virtualName")
.build()))
.ebsOptimized(false)
.iamInstanceProfile(IamInstanceProfileSpecificationProperty.builder()
.arn("arn")
.build())
.instanceRequirements(InstanceRequirementsRequestProperty.builder()
.acceleratorCount(AcceleratorCountRequestProperty.builder()
.max(123)
.min(123)
.build())
.acceleratorManufacturers(List.of("acceleratorManufacturers"))
.acceleratorNames(List.of("acceleratorNames"))
.acceleratorTotalMemoryMiB(AcceleratorTotalMemoryMiBRequestProperty.builder()
.max(123)
.min(123)
.build())
.acceleratorTypes(List.of("acceleratorTypes"))
.allowedInstanceTypes(List.of("allowedInstanceTypes"))
.bareMetal("bareMetal")
.baselineEbsBandwidthMbps(BaselineEbsBandwidthMbpsRequestProperty.builder()
.max(123)
.min(123)
.build())
.baselinePerformanceFactors(BaselinePerformanceFactorsRequestProperty.builder()
.cpu(CpuPerformanceFactorRequestProperty.builder()
.references(List.of(PerformanceFactorReferenceRequestProperty.builder()
.instanceFamily("instanceFamily")
.build()))
.build())
.build())
.burstablePerformance("burstablePerformance")
.cpuManufacturers(List.of("cpuManufacturers"))
.excludedInstanceTypes(List.of("excludedInstanceTypes"))
.instanceGenerations(List.of("instanceGenerations"))
.localStorage("localStorage")
.localStorageTypes(List.of("localStorageTypes"))
.maxSpotPriceAsPercentageOfOptimalOnDemandPrice(123)
.memoryGiBPerVCpu(MemoryGiBPerVCpuRequestProperty.builder()
.max(123)
.min(123)
.build())
.memoryMiB(MemoryMiBRequestProperty.builder()
.max(123)
.min(123)
.build())
.networkBandwidthGbps(NetworkBandwidthGbpsRequestProperty.builder()
.max(123)
.min(123)
.build())
.networkInterfaceCount(NetworkInterfaceCountRequestProperty.builder()
.max(123)
.min(123)
.build())
.onDemandMaxPricePercentageOverLowestPrice(123)
.requireHibernateSupport(false)
.spotMaxPricePercentageOverLowestPrice(123)
.totalLocalStorageGb(TotalLocalStorageGBRequestProperty.builder()
.max(123)
.min(123)
.build())
.vCpuCount(VCpuCountRangeRequestProperty.builder()
.max(123)
.min(123)
.build())
.build())
.instanceType("instanceType")
.kernelId("kernelId")
.keyName("keyName")
.monitoring(SpotFleetMonitoringProperty.builder()
.enabled(false)
.build())
.networkInterfaces(List.of(InstanceNetworkInterfaceSpecificationProperty.builder()
.associatePublicIpAddress(false)
.deleteOnTermination(false)
.description("description")
.deviceIndex(123)
.groups(List.of("groups"))
.ipv6AddressCount(123)
.ipv6Addresses(List.of(InstanceIpv6AddressProperty.builder()
.ipv6Address("ipv6Address")
.build()))
.networkInterfaceId("networkInterfaceId")
.privateIpAddresses(List.of(PrivateIpAddressSpecificationProperty.builder()
.privateIpAddress("privateIpAddress")
// the properties below are optional
.primary(false)
.build()))
.secondaryPrivateIpAddressCount(123)
.subnetId("subnetId")
.build()))
.placement(SpotPlacementProperty.builder()
.availabilityZone("availabilityZone")
.groupName("groupName")
.tenancy("tenancy")
.build())
.ramdiskId("ramdiskId")
.securityGroups(List.of(GroupIdentifierProperty.builder()
.groupId("groupId")
.build()))
.spotPrice("spotPrice")
.subnetId("subnetId")
.tagSpecifications(List.of(SpotFleetTagSpecificationProperty.builder()
.resourceType("resourceType")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.build()))
.userData("userData")
.weightedCapacity(123)
.build()))
.launchTemplateConfigs(List.of(LaunchTemplateConfigProperty.builder()
.launchTemplateSpecification(FleetLaunchTemplateSpecificationProperty.builder()
.version("version")
// the properties below are optional
.launchTemplateId("launchTemplateId")
.launchTemplateName("launchTemplateName")
.build())
.overrides(List.of(LaunchTemplateOverridesProperty.builder()
.availabilityZone("availabilityZone")
.instanceRequirements(InstanceRequirementsRequestProperty.builder()
.acceleratorCount(AcceleratorCountRequestProperty.builder()
.max(123)
.min(123)
.build())
.acceleratorManufacturers(List.of("acceleratorManufacturers"))
.acceleratorNames(List.of("acceleratorNames"))
.acceleratorTotalMemoryMiB(AcceleratorTotalMemoryMiBRequestProperty.builder()
.max(123)
.min(123)
.build())
.acceleratorTypes(List.of("acceleratorTypes"))
.allowedInstanceTypes(List.of("allowedInstanceTypes"))
.bareMetal("bareMetal")
.baselineEbsBandwidthMbps(BaselineEbsBandwidthMbpsRequestProperty.builder()
.max(123)
.min(123)
.build())
.baselinePerformanceFactors(BaselinePerformanceFactorsRequestProperty.builder()
.cpu(CpuPerformanceFactorRequestProperty.builder()
.references(List.of(PerformanceFactorReferenceRequestProperty.builder()
.instanceFamily("instanceFamily")
.build()))
.build())
.build())
.burstablePerformance("burstablePerformance")
.cpuManufacturers(List.of("cpuManufacturers"))
.excludedInstanceTypes(List.of("excludedInstanceTypes"))
.instanceGenerations(List.of("instanceGenerations"))
.localStorage("localStorage")
.localStorageTypes(List.of("localStorageTypes"))
.maxSpotPriceAsPercentageOfOptimalOnDemandPrice(123)
.memoryGiBPerVCpu(MemoryGiBPerVCpuRequestProperty.builder()
.max(123)
.min(123)
.build())
.memoryMiB(MemoryMiBRequestProperty.builder()
.max(123)
.min(123)
.build())
.networkBandwidthGbps(NetworkBandwidthGbpsRequestProperty.builder()
.max(123)
.min(123)
.build())
.networkInterfaceCount(NetworkInterfaceCountRequestProperty.builder()
.max(123)
.min(123)
.build())
.onDemandMaxPricePercentageOverLowestPrice(123)
.requireHibernateSupport(false)
.spotMaxPricePercentageOverLowestPrice(123)
.totalLocalStorageGb(TotalLocalStorageGBRequestProperty.builder()
.max(123)
.min(123)
.build())
.vCpuCount(VCpuCountRangeRequestProperty.builder()
.max(123)
.min(123)
.build())
.build())
.instanceType("instanceType")
.priority(123)
.spotPrice("spotPrice")
.subnetId("subnetId")
.weightedCapacity(123)
.build()))
.build()))
.loadBalancersConfig(LoadBalancersConfigProperty.builder()
.classicLoadBalancersConfig(ClassicLoadBalancersConfigProperty.builder()
.classicLoadBalancers(List.of(ClassicLoadBalancerProperty.builder()
.name("name")
.build()))
.build())
.targetGroupsConfig(TargetGroupsConfigProperty.builder()
.targetGroups(List.of(TargetGroupProperty.builder()
.arn("arn")
.build()))
.build())
.build())
.onDemandAllocationStrategy("onDemandAllocationStrategy")
.onDemandMaxTotalPrice("onDemandMaxTotalPrice")
.onDemandTargetCapacity(123)
.replaceUnhealthyInstances(false)
.spotMaintenanceStrategies(SpotMaintenanceStrategiesProperty.builder()
.capacityRebalance(SpotCapacityRebalanceProperty.builder()
.replacementStrategy("replacementStrategy")
.terminationDelay(123)
.build())
.build())
.spotMaxTotalPrice("spotMaxTotalPrice")
.spotPrice("spotPrice")
.tagSpecifications(List.of(SpotFleetTagSpecificationProperty.builder()
.resourceType("resourceType")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.build()))
.targetCapacityUnitType("targetCapacityUnitType")
.terminateInstancesWithExpiration(false)
.type("type")
.validFrom("validFrom")
.validUntil("validUntil")
.build())
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe minimum and maximum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) on an instance.static interfaceThe minimum and maximum amount of total accelerator memory, in MiB.static interfaceThe minimum and maximum baseline bandwidth to Amazon EBS, in Mbps.static interfaceThe baseline performance to consider, using an instance family as a baseline reference.static interfaceSpecifies a block device mapping.static final classA fluent builder forCfnSpotFleet.static interfaceSpecifies a Classic Load Balancer.static interfaceSpecifies the Classic Load Balancers to attach to a Spot Fleet.static interfaceThe CPU performance to consider, using an instance family as the baseline reference.static interfaceDescribes a block device for an EBS volume.static interfaceSpecifies the launch template to be used by the Spot Fleet request for configuring Amazon EC2 instances.static interfaceDescribes a security group.static interfaceDescribes an IAM instance profile.static interfaceDescribes an IPv6 address.static interfaceDescribes a network interface.static interfaceThe attributes for the instance types.static interfaceSpecifies a launch template and overrides.static interfaceSpecifies overrides for a launch template.static interfaceSpecifies the Classic Load Balancers and target groups to attach to a Spot Fleet request.static interfaceThe minimum and maximum amount of memory per vCPU, in GiB.static interfaceThe minimum and maximum amount of memory, in MiB.static interfaceThe minimum and maximum amount of baseline network bandwidth, in gigabits per second (Gbps).static interfaceThe minimum and maximum number of network interfaces.static interfaceSpecify an instance family to use as the baseline reference for CPU performance.static interfaceDescribes a secondary private IPv4 address for a network interface.static interfaceThe Spot Instance replacement strategy to use when Amazon EC2 emits a signal that your Spot Instance is at an elevated risk of being interrupted.static interfaceSpecifies the launch specification for one or more Spot Instances.static interfaceDescribes whether monitoring is enabled.static interfaceSpecifies the configuration of a Spot Fleet request.static interfaceThe tags for a Spot Fleet resource.static interfaceThe strategies for managing your Spot Instances that are at an elevated risk of being interrupted.static interfaceDescribes Spot Instance placement.static interfaceDescribes a load balancer target group.static interfaceDescribes the target groups to attach to a Spot Fleet.static interfaceThe minimum and maximum amount of total local storage, in GB.static interfaceThe minimum and maximum number of vCPUs.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.ec2.ISpotFleetRef
ISpotFleetRef.Jsii$Default, ISpotFleetRef.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnSpotFleet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnSpotFleet(software.amazon.jsii.JsiiObjectRef objRef) CfnSpotFleet(software.constructs.Construct scope, String id, CfnSpotFleetProps props) Create a newAWS::EC2::SpotFleet. -
Method Summary
Modifier and TypeMethodDescriptionThe ID of the Spot Fleet.A reference to a SpotFleet resource.Describes the configuration of a Spot Fleet request.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.static BooleanChecks whether the given object is a CfnSpotFleet.renderProperties(Map<String, Object> props) voidDescribes the configuration of a Spot Fleet request.voidDescribes the configuration of a Spot Fleet request.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnSpotFleet
protected CfnSpotFleet(software.amazon.jsii.JsiiObjectRef objRef) -
CfnSpotFleet
protected CfnSpotFleet(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnSpotFleet
@Stability(Stable) public CfnSpotFleet(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnSpotFleetProps props) Create a newAWS::EC2::SpotFleet.- Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
isCfnSpotFleet
Checks whether the given object is a CfnSpotFleet.- Parameters:
x- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrId
The ID of the Spot Fleet. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getSpotFleetRef
A reference to a SpotFleet resource.- Specified by:
getSpotFleetRefin interfaceISpotFleetRef
-
getSpotFleetRequestConfigData
Describes the configuration of a Spot Fleet request.Returns union: either
IResolvableorCfnSpotFleet.SpotFleetRequestConfigDataProperty -
setSpotFleetRequestConfigData
Describes the configuration of a Spot Fleet request. -
setSpotFleetRequestConfigData
@Stability(Stable) public void setSpotFleetRequestConfigData(@NotNull CfnSpotFleet.SpotFleetRequestConfigDataProperty value) Describes the configuration of a Spot Fleet request.
-