Table of Contents

Class MixedInstancesPolicy

Namespace
Amazon.CDK.AWS.AutoScaling
Assembly
Amazon.CDK.AWS.AutoScaling.dll

MixedInstancesPolicy allows you to configure a group that diversifies across On-Demand Instances and Spot Instances of multiple instance types.

public class MixedInstancesPolicy : IMixedInstancesPolicy
Inheritance
MixedInstancesPolicy
Implements
Inherited Members

Examples

Vpc vpc;
             LaunchTemplate launchTemplate1;
             LaunchTemplate launchTemplate2;


             new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
                 Vpc = vpc,
                 MixedInstancesPolicy = new MixedInstancesPolicy {
                     InstancesDistribution = new InstancesDistribution {
                         OnDemandPercentageAboveBaseCapacity = 50
                     },
                     LaunchTemplate = launchTemplate1,
                     LaunchTemplateOverrides = new [] { new LaunchTemplateOverrides { InstanceType = new InstanceType("t3.micro") }, new LaunchTemplateOverrides { InstanceType = new InstanceType("t3a.micro") }, new LaunchTemplateOverrides { InstanceType = new InstanceType("t4g.micro"), LaunchTemplate = launchTemplate2 } }
                 }
             });

Remarks

For more information, see Auto Scaling groups with multiple instance types and purchase options in the Amazon EC2 Auto Scaling User Guide:

https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-purchase-options.html

ExampleMetadata: infused

Constructors

MixedInstancesPolicy()

public MixedInstancesPolicy()

Properties

InstancesDistribution

InstancesDistribution to use.

public IInstancesDistribution? InstancesDistribution { get; set; }

Property Value

IInstancesDistribution

Remarks

Default: - The value for each property in it uses a default value.

LaunchTemplate

Launch template to use.

public ILaunchTemplate LaunchTemplate { get; set; }

Property Value

ILaunchTemplate

LaunchTemplateOverrides

Launch template overrides.

public ILaunchTemplateOverrides[]? LaunchTemplateOverrides { get; set; }

Property Value

ILaunchTemplateOverrides[]

Remarks

The maximum number of instance types that can be associated with an Auto Scaling group is 40.

The maximum number of distinct launch templates you can define for an Auto Scaling group is 20.

Default: - Do not provide any overrides