# 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](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-mixed-instances-groups.html) 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](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-autoscalinggroup.html) resource.

- Source: Generated code
- Type last changed: v2.93.0 · 23 Aug 2023

## Example

```ts
// 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: [{
      imageId: 'imageId',
      instanceRequirements: {
        memoryMiB: {
          max: 123,
          min: 123,
        },
        vCpuCount: {
          max: 123,
          min: 123,
        },

        // the properties below are optional
        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,
        },
        baselinePerformanceFactors: {
          cpu: {
            references: [{
              instanceFamily: 'instanceFamily',
            }],
          },
        },
        burstablePerformance: 'burstablePerformance',
        cpuManufacturers: ['cpuManufacturers'],
        excludedInstanceTypes: ['excludedInstanceTypes'],
        instanceGenerations: ['instanceGenerations'],
        localStorage: 'localStorage',
        localStorageTypes: ['localStorageTypes'],
        maxSpotPriceAsPercentageOfOptimalOnDemandPrice: 123,
        memoryGiBPerVCpu: {
          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,
        },
      },
      instanceType: 'instanceType',
      launchTemplateSpecification: {
        version: 'version',

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

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

## Properties

- `instancesDistribution`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAutoScalingGroup.InstancesDistributionProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.CfnAutoScalingGroup.InstancesDistributionProperty.html) — The instances distribution.

- `launchTemplate`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAutoScalingGroup.LaunchTemplateProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.CfnAutoScalingGroup.LaunchTemplateProperty.html) (required) — One or more launch templates and the instance types (overrides) that are used to launch EC2 instances to fulfill On-Demand and Spot capacities.
