Class: AWSCDK::EC2::LaunchTemplateSpotOptions

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ec2/launch_template_spot_options.rb

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block_duration: nil, interruption_behavior: nil, max_price: nil, request_type: nil, valid_until: nil) ⇒ LaunchTemplateSpotOptions

Returns a new instance of LaunchTemplateSpotOptions.

Parameters:

  • block_duration (AWSCDK::Duration, nil) (defaults to: nil)

    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.

  • interruption_behavior (AWSCDK::EC2::SpotInstanceInterruption, nil) (defaults to: nil)

    The behavior when a Spot Instance is interrupted.

  • max_price (Numeric, nil) (defaults to: nil)

    Maximum hourly price you're willing to pay for each Spot instance.

  • request_type (AWSCDK::EC2::SpotRequestType, nil) (defaults to: nil)

    The Spot Instance request type.

  • valid_until (AWSCDK::Expiration, nil) (defaults to: nil)

    The end date of the request.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'ec2/launch_template_spot_options.rb', line 12

def initialize(block_duration: nil, interruption_behavior: nil, max_price: nil, request_type: nil, valid_until: nil)
  @block_duration = block_duration
  Jsii::Type.check_type(@block_duration, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "blockDuration") unless @block_duration.nil?
  @interruption_behavior = interruption_behavior
  Jsii::Type.check_type(@interruption_behavior, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlNwb3RJbnN0YW5jZUludGVycnVwdGlvbiJ9")), "interruptionBehavior") unless @interruption_behavior.nil?
  @max_price = max_price
  Jsii::Type.check_type(@max_price, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "maxPrice") unless @max_price.nil?
  @request_type = request_type
  Jsii::Type.check_type(@request_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlNwb3RSZXF1ZXN0VHlwZSJ9")), "requestType") unless @request_type.nil?
  @valid_until = valid_until
  Jsii::Type.check_type(@valid_until, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5FeHBpcmF0aW9uIn0=")), "validUntil") unless @valid_until.nil?
end

Instance Attribute Details

#block_durationAWSCDK::Duration? (readonly)

Note:

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

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.



32
33
34
# File 'ec2/launch_template_spot_options.rb', line 32

def block_duration
  @block_duration
end

#interruption_behaviorAWSCDK::EC2::SpotInstanceInterruption? (readonly)

Note:

Default: Spot instances will terminate when interrupted.

The behavior when a Spot Instance is interrupted.



37
38
39
# File 'ec2/launch_template_spot_options.rb', line 37

def interruption_behavior
  @interruption_behavior
end

#max_priceNumeric? (readonly)

Note:

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

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.

Returns:

  • (Numeric, nil)


45
46
47
# File 'ec2/launch_template_spot_options.rb', line 45

def max_price
  @max_price
end

#request_typeAWSCDK::EC2::SpotRequestType? (readonly)

Note:

Default: 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.



54
55
56
# File 'ec2/launch_template_spot_options.rb', line 54

def request_type
  @request_type
end

#valid_untilAWSCDK::Expiration? (readonly)

Note:

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

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.

Returns:



63
64
65
# File 'ec2/launch_template_spot_options.rb', line 63

def valid_until
  @valid_until
end

Class Method Details

.jsii_propertiesObject



65
66
67
68
69
70
71
72
73
# File 'ec2/launch_template_spot_options.rb', line 65

def self.jsii_properties
  {
    :block_duration => "blockDuration",
    :interruption_behavior => "interruptionBehavior",
    :max_price => "maxPrice",
    :request_type => "requestType",
    :valid_until => "validUntil",
  }
end

Instance Method Details

#to_jsiiObject



75
76
77
78
79
80
81
82
83
84
85
# File 'ec2/launch_template_spot_options.rb', line 75

def to_jsii
  result = {}
  result.merge!({
    "blockDuration" => @block_duration,
    "interruptionBehavior" => @interruption_behavior,
    "maxPrice" => @max_price,
    "requestType" => @request_type,
    "validUntil" => @valid_until,
  })
  result.compact
end