Skip to content
v2.273.0

LaunchTemplateSpotOptions Struct ​

Interface for the Spot market instance options provided in a LaunchTemplate.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';

declare const expiration: cdk.Expiration;
const launchTemplateSpotOptions: ec2.LaunchTemplateSpotOptions = {
  blockDuration: cdk.Duration.minutes(30),
  interruptionBehavior: ec2.SpotInstanceInterruption.STOP,
  maxPrice: 123,
  requestType: ec2.SpotRequestType.ONE_TIME,
  validUntil: expiration,
};

Properties ​

blockDurationDurationblock_durationDurationblockDurationDurationBlockDurationDurationBlockDurationDuration= Requested spot instances do not …#
Spot Instances with a defined duration (also known as Spot blocks) are designed not to be interrupted and will run continuously for the duration you select.

You can use a duration of 1, 2, 3, 4, 5, or 6 hours.

default

Default: Requested spot instances do not have a pre-defined duration.

interruptionBehaviorSpotInstanceInterruptioninterruption_behaviorSpotInstanceInterruptioninterruptionBehaviorSpotInstanceInterruptionInterruptionBehaviorSpotInstanceInterruptionInterruptionBehaviorSpotInstanceInterruption= Spot instances will terminate wh…#
The behavior when a Spot Instance is interrupted.
default

Default: Spot instances will terminate when interrupted.

maxPricenumbermax_priceint | floatmaxPriceNumberMaxPricedoubleMaxPrice*float64= Maximum hourly price will defaul…#
Maximum hourly price you're willing to pay for each Spot instance.

The value is given in dollars. ex: 0.01 for 1 cent per hour, or 0.001 for one-tenth of a cent per hour.

default

Default: Maximum hourly price will default to the on-demand price for the instance type.

requestTypeSpotRequestTyperequest_typeSpotRequestTyperequestTypeSpotRequestTypeRequestTypeSpotRequestTypeRequestTypeSpotRequestType= One-time spot request.#
The Spot Instance request type.

If you are using Spot Instances with an Auto Scaling group, use one-time requests, as the Amazon EC2 Auto Scaling service handles requesting new Spot Instances whenever the group is below its desired capacity.

validUntilExpirationvalid_untilExpirationvalidUntilExpirationValidUntilExpirationValidUntilExpiration= The default end date is 7 days f…#
The end date of the request.

For a one-time request, the request remains active until all instances launch, the request is canceled, or this date is reached. If the request is persistent, it remains active until it is canceled or this date and time is reached.

default

Default: The default end date is 7 days from the current date.