Skip to content
v2.273.0

MixedInstancesPolicy Struct ​

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

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

Example ​

ts
declare const vpc: ec2.Vpc;
declare const launchTemplate1: ec2.LaunchTemplate;
declare const launchTemplate2: ec2.LaunchTemplate;

new autoscaling.AutoScalingGroup(this, 'ASG', {
  vpc,
  mixedInstancesPolicy: {
    instancesDistribution: {
      onDemandPercentageAboveBaseCapacity: 50, // Mix Spot and On-Demand instances
    },
    launchTemplate: launchTemplate1,
    launchTemplateOverrides: [ // Mix multiple instance types
      { instanceType: new ec2.InstanceType('t3.micro') },
      { instanceType: new ec2.InstanceType('t3a.micro') },
      { instanceType: new ec2.InstanceType('t4g.micro'), launchTemplate: launchTemplate2 },
    ],
  }
});

Properties ​

instancesDistributionInstancesDistributioninstances_distributionInstancesDistributioninstancesDistributionInstancesDistributionInstancesDistributionInstancesDistributionInstancesDistributionInstancesDistribution= The value for each property in i…#
InstancesDistribution to use.
default

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

launchTemplateILaunchTemplatelaunch_templateILaunchTemplatelaunchTemplateILaunchTemplateLaunchTemplateILaunchTemplateLaunchTemplateILaunchTemplaterequired#
Launch template to use.
launchTemplateOverridesLaunchTemplateOverrides[]launch_template_overridestyping.List[LaunchTemplateOverrides]launchTemplateOverridesList<LaunchTemplateOverrides>LaunchTemplateOverridesLaunchTemplateOverrides[]LaunchTemplateOverrides*[]LaunchTemplateOverrides= Do not provide any overrides#
Launch template overrides.

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.