interface MixedInstancesPolicy
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.AutoScaling.MixedInstancesPolicy |
Java | software.amazon.awscdk.services.autoscaling.MixedInstancesPolicy |
Python | aws_cdk.aws_autoscaling.MixedInstancesPolicy |
TypeScript (source) | @aws-cdk/aws-autoscaling » MixedInstancesPolicy |
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
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
Name | Type | Description |
---|---|---|
launch | ILaunch | Launch template to use. |
instances | Instances | InstancesDistribution to use. |
launch | Launch [] | Launch template overrides. |
launchTemplate
Type:
ILaunch
Launch template to use.
instancesDistribution?
Type:
Instances
(optional, default: The value for each property in it uses a default value.)
InstancesDistribution to use.
launchTemplateOverrides?
Type:
Launch
[]
(optional, default: 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.