LaunchTemplateSpotOptions Struct
Interface for the Spot market instance options provided in a LaunchTemplate.
| Source | aws-ec2/lib/launch-template.ts |
|---|
Example
// 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,
};
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
# expiration: cdk.Expiration
launch_template_spot_options = ec2.LaunchTemplateSpotOptions(
block_duration=cdk.Duration.minutes(30),
interruption_behavior=ec2.SpotInstanceInterruption.STOP,
max_price=123,
request_type=ec2.SpotRequestType.ONE_TIME,
valid_until=expiration
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
Expiration expiration;
LaunchTemplateSpotOptions launchTemplateSpotOptions = LaunchTemplateSpotOptions.builder()
.blockDuration(Duration.minutes(30))
.interruptionBehavior(SpotInstanceInterruption.STOP)
.maxPrice(123)
.requestType(SpotRequestType.ONE_TIME)
.validUntil(expiration)
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
Expiration expiration;
var launchTemplateSpotOptions = new LaunchTemplateSpotOptions {
BlockDuration = Duration.Minutes(30),
InterruptionBehavior = SpotInstanceInterruption.STOP,
MaxPrice = 123,
RequestType = SpotRequestType.ONE_TIME,
ValidUntil = expiration
};
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var expiration Expiration
launchTemplateSpotOptions := &LaunchTemplateSpotOptions{
BlockDuration: cdk.Duration_Minutes(jsii.Number(30)),
InterruptionBehavior: awscdk.Aws_ec2.SpotInstanceInterruption_STOP,
MaxPrice: jsii.Number(123),
RequestType: awscdk.*Aws_ec2.SpotRequestType_ONE_TIME,
ValidUntil: expiration,
}
Properties
blockDurationoptionalDurationblock_durationoptionalDurationblockDurationoptionalDurationBlockDurationoptionalDurationBlockDurationoptionalDuration #Default: Requested spot instances do not have a pre-defined duration.
You can use a duration of 1, 2, 3, 4, 5, or 6 hours.
interruptionBehavioroptionalSpotInstanceInterruptioninterruption_behavioroptionalSpotInstanceInterruptioninterruptionBehavioroptionalSpotInstanceInterruptionInterruptionBehavioroptionalSpotInstanceInterruptionInterruptionBehavioroptionalSpotInstanceInterruption #Default: Spot instances will terminate when interrupted.
maxPriceoptionalnumbermax_priceoptionalint | floatmaxPriceoptionalNumberMaxPriceoptionaldoubleMaxPriceoptional*float64 #Default: Maximum hourly price will default to the on-demand price for the instance type.
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.
requestTypeoptionalSpotRequestTyperequest_typeoptionalSpotRequestTyperequestTypeoptionalSpotRequestTypeRequestTypeoptionalSpotRequestTypeRequestTypeoptionalSpotRequestType #Default: One-time spot request.
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.
validUntiloptionalExpirationvalid_untiloptionalExpirationvalidUntiloptionalExpirationValidUntiloptionalExpirationValidUntiloptionalExpiration #Default: The default end date is 7 days from the current date.
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.