aws-cdk-lib.aws_autoscaling.CfnAutoScalingGroup.MixedInstancesPolicyProperty

interface MixedInstancesPolicyProperty

LanguageType name
.NETAmazon.CDK.AWS.AutoScaling.CfnAutoScalingGroup.MixedInstancesPolicyProperty
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsautoscaling#CfnAutoScalingGroup_MixedInstancesPolicyProperty
Javasoftware.amazon.awscdk.services.autoscaling.CfnAutoScalingGroup.MixedInstancesPolicyProperty
Pythonaws_cdk.aws_autoscaling.CfnAutoScalingGroup.MixedInstancesPolicyProperty
TypeScript aws-cdk-lib » aws_autoscaling » CfnAutoScalingGroup » MixedInstancesPolicyProperty

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.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
const mixedInstancesPolicyProperty: autoscaling.CfnAutoScalingGroup.MixedInstancesPolicyProperty = {
  launchTemplate: {
    launchTemplateSpecification: {
      version: 'version',

      // the properties below are optional
      launchTemplateId: 'launchTemplateId',
      launchTemplateName: 'launchTemplateName',
    },

    // the properties below are optional
    overrides: [{
      instanceRequirements: {
        acceleratorCount: {
          max: 123,
          min: 123,
        },
        acceleratorManufacturers: ['acceleratorManufacturers'],
        acceleratorNames: ['acceleratorNames'],
        acceleratorTotalMemoryMiB: {
          max: 123,
          min: 123,
        },
        acceleratorTypes: ['acceleratorTypes'],
        allowedInstanceTypes: ['allowedInstanceTypes'],
        bareMetal: 'bareMetal',
        baselineEbsBandwidthMbps: {
          max: 123,
          min: 123,
        },
        burstablePerformance: 'burstablePerformance',
        cpuManufacturers: ['cpuManufacturers'],
        excludedInstanceTypes: ['excludedInstanceTypes'],
        instanceGenerations: ['instanceGenerations'],
        localStorage: 'localStorage',
        localStorageTypes: ['localStorageTypes'],
        memoryGiBPerVCpu: {
          max: 123,
          min: 123,
        },
        memoryMiB: {
          max: 123,
          min: 123,
        },
        networkBandwidthGbps: {
          max: 123,
          min: 123,
        },
        networkInterfaceCount: {
          max: 123,
          min: 123,
        },
        onDemandMaxPricePercentageOverLowestPrice: 123,
        requireHibernateSupport: false,
        spotMaxPricePercentageOverLowestPrice: 123,
        totalLocalStorageGb: {
          max: 123,
          min: 123,
        },
        vCpuCount: {
          max: 123,
          min: 123,
        },
      },
      instanceType: 'instanceType',
      launchTemplateSpecification: {
        version: 'version',

        // the properties below are optional
        launchTemplateId: 'launchTemplateId',
        launchTemplateName: 'launchTemplateName',
      },
      weightedCapacity: 'weightedCapacity',
    }],
  },

  // the properties below are optional
  instancesDistribution: {
    onDemandAllocationStrategy: 'onDemandAllocationStrategy',
    onDemandBaseCapacity: 123,
    onDemandPercentageAboveBaseCapacity: 123,
    spotAllocationStrategy: 'spotAllocationStrategy',
    spotInstancePools: 123,
    spotMaxPrice: 'spotMaxPrice',
  },
};

Properties

NameTypeDescription
launchTemplateIResolvable | LaunchTemplatePropertyOne or more launch templates and the instance types (overrides) that are used to launch EC2 instances to fulfill On-Demand and Spot capacities.
instancesDistribution?IResolvable | InstancesDistributionPropertyThe instances distribution.

launchTemplate

Type: IResolvable | LaunchTemplateProperty

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


instancesDistribution?

Type: IResolvable | InstancesDistributionProperty (optional)

The instances distribution.