cancelSpotFleetRequests
inline suspend fun Ec2Client.cancelSpotFleetRequests(crossinline block: CancelSpotFleetRequestsRequest.Builder.() -> Unit): CancelSpotFleetRequestsResponse
Cancels the specified Spot Fleet requests.
After you cancel a Spot Fleet request, the Spot Fleet launches no new instances.
You must also specify whether a canceled Spot Fleet request should terminate its instances. If you choose to terminate the instances, the Spot Fleet request enters the cancelled_terminating
state. Otherwise, the Spot Fleet request enters the cancelled_running
state and the instances continue to run until they are interrupted or you terminate them manually.
Restrictions
You can delete up to 100 fleets in a single request. If you exceed the specified number, no fleets are deleted.
Samples
fun main() {
//sampleStart
// This example cancels the specified Spot fleet request and terminates its associated Spot Instances.
val resp = ec2Client.cancelSpotFleetRequests {
spotFleetRequestIds = listOf<String>(
"sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"
)
terminateInstances = true
}
//sampleEnd
}
fun main() {
//sampleStart
// This example cancels the specified Spot fleet request without terminating its associated Spot
// Instances.
val resp = ec2Client.cancelSpotFleetRequests {
spotFleetRequestIds = listOf<String>(
"sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"
)
terminateInstances = false
}
//sampleEnd
}