MixedInstancesPolicy

class aws_cdk.aws_autoscaling.MixedInstancesPolicy(*, launch_template, instances_distribution=None, launch_template_overrides=None)

Bases: object

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

Parameters:
  • launch_template (ILaunchTemplate) – Launch template to use.

  • instances_distribution (Union[InstancesDistribution, Dict[str, Any], None]) – InstancesDistribution to use. Default: - The value for each property in it uses a default value.

  • launch_template_overrides (Optional[Sequence[Union[LaunchTemplateOverrides, Dict[str, Any]]]]) – 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. Default: - Do not provide any overrides

ExampleMetadata:

infused

Example:

# vpc: ec2.Vpc
# launch_template1: ec2.LaunchTemplate
# launch_template2: ec2.LaunchTemplate


autoscaling.AutoScalingGroup(self, "ASG",
    vpc=vpc,
    mixed_instances_policy=autoscaling.MixedInstancesPolicy(
        instances_distribution=autoscaling.InstancesDistribution(
            on_demand_percentage_above_base_capacity=50
        ),
        launch_template=launch_template1,
        launch_template_overrides=[autoscaling.LaunchTemplateOverrides(instance_type=ec2.InstanceType("t3.micro")), autoscaling.LaunchTemplateOverrides(instance_type=ec2.InstanceType("t3a.micro")), autoscaling.LaunchTemplateOverrides(instance_type=ec2.InstanceType("t4g.micro"), launch_template=launch_template2)]
    )
)

Attributes

instances_distribution

InstancesDistribution to use.

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

launch_template

Launch template to use.

launch_template_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.

Default:
  • Do not provide any overrides