Skip to content

Commit c1c800e

Browse files
authored
chore(applicationautoscaling): add missing PredefinedMetricType enum values (#31115)
### Issue # (if applicable) Closes #31113 ### Reason for this change There are three `PredefinedMetricType` values missing from the enum: * SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution * SageMakerVariantConcurrentRequestsPerModelHighResolution * WorkSpacesAverageUserSessionsCapacityUtilization https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html ### Description of changes Adds the missing enums ### Description of how you validated changes Added unit tests ### Checklist - [ X ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c159e77 commit c1c800e

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

packages/aws-cdk-lib/aws-applicationautoscaling/lib/target-tracking-scaling-policy.ts

+15
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,19 @@ export enum PredefinedMetric {
304304
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
305305
*/
306306
ELASTICACHE_DATABASE_CAPACITY_USAGE_COUNTED_FOR_EVICT_PERCENTAGE = 'ElastiCacheDatabaseCapacityUsageCountedForEvictPercentage',
307+
/**
308+
* SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION
309+
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
310+
*/
311+
SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION = 'SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution',
312+
/**
313+
* SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION
314+
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
315+
*/
316+
SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION = 'SageMakerVariantConcurrentRequestsPerModelHighResolution',
317+
/**
318+
* WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION
319+
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
320+
*/
321+
WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION = 'WorkSpacesAverageUserSessionsCapacityUtilization',
307322
}

packages/aws-cdk-lib/aws-applicationautoscaling/test/target-tracking.test.ts

+60
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,66 @@ describe('target tracking', () => {
9191
});
9292
});
9393

94+
test('test setup target tracking on predefined metric for SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION', () => {
95+
// GIVEN
96+
const stack = new cdk.Stack();
97+
const target = createScalableTarget(stack);
98+
99+
// WHEN
100+
target.scaleToTrackMetric('Tracking', {
101+
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_VARIANT_CONCURRENT_REQUESTS_PER_MODEL_HIGH_RESOLUTION,
102+
targetValue: 0.5,
103+
});
104+
105+
// THEN
106+
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
107+
TargetTrackingScalingPolicyConfiguration: {
108+
PredefinedMetricSpecification: { PredefinedMetricType: 'SageMakerVariantConcurrentRequestsPerModelHighResolution' },
109+
TargetValue: 0.5,
110+
},
111+
});
112+
});
113+
114+
test('test setup target tracking on predefined metric for SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION', () => {
115+
// GIVEN
116+
const stack = new cdk.Stack();
117+
const target = createScalableTarget(stack);
118+
119+
// WHEN
120+
target.scaleToTrackMetric('Tracking', {
121+
predefinedMetric: appscaling.PredefinedMetric.SAGEMAKER_INFERENCE_COMPONENT_CONCURRENT_REQUESTS_PER_COPY_HIGH_RESOLUTION,
122+
targetValue: 0.5,
123+
});
124+
125+
// THEN
126+
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
127+
TargetTrackingScalingPolicyConfiguration: {
128+
PredefinedMetricSpecification: { PredefinedMetricType: 'SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution' },
129+
TargetValue: 0.5,
130+
},
131+
});
132+
});
133+
134+
test('test setup target tracking on predefined metric for WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION', () => {
135+
// GIVEN
136+
const stack = new cdk.Stack();
137+
const target = createScalableTarget(stack);
138+
139+
// WHEN
140+
target.scaleToTrackMetric('Tracking', {
141+
predefinedMetric: appscaling.PredefinedMetric.WORKSPACES_AVERAGE_USER_SESSIONS_CAPACITY_UTILIZATION,
142+
targetValue: 0.5,
143+
});
144+
145+
// THEN
146+
Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalingPolicy', {
147+
TargetTrackingScalingPolicyConfiguration: {
148+
PredefinedMetricSpecification: { PredefinedMetricType: 'WorkSpacesAverageUserSessionsCapacityUtilization' },
149+
TargetValue: 0.5,
150+
},
151+
});
152+
});
153+
94154
test('test setup target tracking on custom metric', () => {
95155
// GIVEN
96156
const stack = new cdk.Stack();

0 commit comments

Comments
 (0)