diff --git a/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts b/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts index 5d7faa17dbf79..1484d7e4df01a 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts @@ -429,6 +429,15 @@ export enum OnDemandAllocationStrategy { * so on. */ PRIORITIZED = 'prioritized', + + /** + * This strategy uses the lowest-price instance types in each Availability Zone based on the current + * On-Demand instance price. + * + * To meet your desired capacity, you might receive On-Demand Instances of more than one instance type + * in each Availability Zone. This depends on how much capacity you request. + */ + LOWEST_PRICE = 'lowest-price', } /** diff --git a/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts b/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts index e6de1020369da..d61e439df1965 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts @@ -2277,6 +2277,43 @@ test('add price-capacity-optimized', () => { }); }); +test('add on-demand lowest-price allocation strategy', () => { + // GIVEN + const stack = new cdk.Stack(); + + // WHEN + const lt = LaunchTemplate.fromLaunchTemplateAttributes(stack, 'imported-lt', { + launchTemplateId: 'test-lt-id', + versionNumber: '0', + }); + + new autoscaling.AutoScalingGroup(stack, 'mip-asg', { + mixedInstancesPolicy: { + launchTemplate: lt, + launchTemplateOverrides: [{ + instanceType: new InstanceType('t4g.micro'), + launchTemplate: lt, + weightedCapacity: 9, + }], + instancesDistribution: { + onDemandAllocationStrategy: OnDemandAllocationStrategy.LOWEST_PRICE, + onDemandBaseCapacity: 1, + onDemandPercentageAboveBaseCapacity: 100, + }, + }, + vpc: mockVpc(stack), + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AutoScaling::AutoScalingGroup', { + MixedInstancesPolicy: { + InstancesDistribution: { + OnDemandAllocationStrategy: 'lowest-price', + }, + }, + }); +}); + test('ssm permissions adds right managed policy', () => { // GIVEN const stack = new cdk.Stack();