Class: AWSCDK::Autoscaling::CfnAutoScalingGroup::MixedInstancesPolicyProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
autoscaling/cfn_auto_scaling_group.rb

Overview

Use this structure to launch multiple instance types and On-Demand Instances and Spot Instances within a single Auto Scaling group.

A mixed instances policy contains information that Amazon EC2 Auto Scaling can use to launch instances and help optimize your costs. For more information, see Auto Scaling groups with multiple instance types and purchase options in the Amazon EC2 Auto Scaling User Guide .

You can create a mixed instances policy for new and existing Auto Scaling groups. You must use a launch template to configure the policy. You cannot use a launch configuration.

There are key differences between Spot Instances and On-Demand Instances:

  • The price for Spot Instances varies based on demand
  • Amazon EC2 can terminate an individual Spot Instance as the availability of, or price for, Spot Instances changes

When a Spot Instance is terminated, Amazon EC2 Auto Scaling group attempts to launch a replacement instance to maintain the desired capacity for the group.

MixedInstancesPolicy is a property of the AWS::AutoScaling::AutoScalingGroup resource.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(launch_template:, instances_distribution: nil) ⇒ MixedInstancesPolicyProperty

Returns a new instance of MixedInstancesPolicyProperty.

Parameters:



2523
2524
2525
2526
2527
2528
# File 'autoscaling/cfn_auto_scaling_group.rb', line 2523

def initialize(launch_template:, instances_distribution: nil)
  @launch_template = launch_template.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnAutoScalingGroup::LaunchTemplateProperty.new(**launch_template.transform_keys(&:to_sym)) : launch_template
  Jsii::Type.check_type(@launch_template, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5BdXRvU2NhbGluZ0dyb3VwLkxhdW5jaFRlbXBsYXRlUHJvcGVydHkifV19fQ==")), "launchTemplate")
  @instances_distribution = instances_distribution.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnAutoScalingGroup::InstancesDistributionProperty.new(**instances_distribution.transform_keys(&:to_sym)) : instances_distribution
  Jsii::Type.check_type(@instances_distribution, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5DZm5BdXRvU2NhbGluZ0dyb3VwLkluc3RhbmNlc0Rpc3RyaWJ1dGlvblByb3BlcnR5In1dfX0=")), "instancesDistribution") unless @instances_distribution.nil?
end

Instance Attribute Details

#instances_distributionAWSCDK::IResolvable, ... (readonly)

The instances distribution.



2539
2540
2541
# File 'autoscaling/cfn_auto_scaling_group.rb', line 2539

def instances_distribution
  @instances_distribution
end

#launch_templateAWSCDK::IResolvable, AWSCDK::Autoscaling::CfnAutoScalingGroup::LaunchTemplateProperty (readonly)

One or more launch templates and the instance types (overrides) that are used to launch EC2 instances to fulfill On-Demand and Spot capacities.



2534
2535
2536
# File 'autoscaling/cfn_auto_scaling_group.rb', line 2534

def launch_template
  @launch_template
end

Class Method Details

.jsii_propertiesObject



2541
2542
2543
2544
2545
2546
# File 'autoscaling/cfn_auto_scaling_group.rb', line 2541

def self.jsii_properties
  {
    :launch_template => "launchTemplate",
    :instances_distribution => "instancesDistribution",
  }
end

Instance Method Details

#to_jsiiObject



2548
2549
2550
2551
2552
2553
2554
2555
# File 'autoscaling/cfn_auto_scaling_group.rb', line 2548

def to_jsii
  result = {}
  result.merge!({
    "launchTemplate" => @launch_template,
    "instancesDistribution" => @instances_distribution,
  })
  result.compact
end