Skip to content

Commit

Permalink
feat: add lowest-price OnDemandAllocationStrategy enum to aws-autosca…
Browse files Browse the repository at this point in the history
…ling
  • Loading branch information
bwagner5 committed Dec 16, 2023
1 parent 1a9c30e commit 2fccd97
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2fccd97

Please sign in to comment.