@gradientedge/cdk-utils 8.41.0 → 8.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -271,6 +271,31 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
271
271
|
this.siteEcsLoadBalancer = fargateService.loadBalancer;
|
|
272
272
|
this.siteEcsTargetGroup = fargateService.targetGroup;
|
|
273
273
|
fargateService.loadBalancer.logAccessLogs(this.siteLogBucket, 'alb');
|
|
274
|
+
if (this.props.siteTask.siteScaling) {
|
|
275
|
+
const scalableTaskCount = this.siteEcsService.autoScaleTaskCount({
|
|
276
|
+
minCapacity: this.props.siteTask.siteScaling.minCapacity,
|
|
277
|
+
maxCapacity: this.props.siteTask.siteScaling.maxCapacity ?? 4,
|
|
278
|
+
});
|
|
279
|
+
if (this.props.siteTask.siteScaling.scaleOnCpuUtilization) {
|
|
280
|
+
scalableTaskCount.scaleOnCpuUtilization(`${this.id}-cpu-scaling`, {
|
|
281
|
+
targetUtilizationPercent: this.props.siteTask.siteScaling.scaleOnCpuUtilization ?? 50,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
if (this.props.siteTask.siteScaling.scaleOnMemoryUtilization) {
|
|
285
|
+
scalableTaskCount.scaleOnMemoryUtilization(`${this.id}-mem-scaling`, {
|
|
286
|
+
targetUtilizationPercent: this.props.siteTask.siteScaling.scaleOnMemoryUtilization ?? 50,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (this.props.siteTask.siteScaling.scaleOnRequestsPerTarget) {
|
|
290
|
+
scalableTaskCount.scaleOnRequestCount(`${this.id}-req-count`, {
|
|
291
|
+
requestsPerTarget: this.props.siteTask.siteScaling.scaleOnRequestsPerTarget ?? 10000,
|
|
292
|
+
targetGroup: this.siteEcsTargetGroup,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (this.props.siteTask.siteScaling.scaleOnSchedule) {
|
|
296
|
+
scalableTaskCount.scaleOnSchedule(`${this.id}-schedule`, this.props.siteTask.siteScaling.scaleOnSchedule);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
274
299
|
/* if enabled, add efs with access point and mount */
|
|
275
300
|
if (this.props.siteFileSystem) {
|
|
276
301
|
this.siteFileSystem = this.efsManager.createFileSystem(`${this.id}-fs`, this, this.props.siteFileSystem, this.siteVpc, this.props.siteFileSystemAccessPoints);
|
|
@@ -28,6 +28,7 @@ import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
|
|
|
28
28
|
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
29
29
|
import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
|
|
30
30
|
import * as types from '../index';
|
|
31
|
+
import * as appAutoscaling from 'aws-cdk-lib/aws-applicationautoscaling';
|
|
31
32
|
/**
|
|
32
33
|
* @category cdk-utils.app-config-manager
|
|
33
34
|
* @subcategory Properties
|
|
@@ -621,6 +622,14 @@ export interface EcsClusterProps extends ecs.ClusterProps {
|
|
|
621
622
|
export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
622
623
|
logging?: ecs.AwsLogDriverProps;
|
|
623
624
|
}
|
|
625
|
+
export interface EcsScalingProps {
|
|
626
|
+
minCapacity?: number;
|
|
627
|
+
maxCapacity?: number;
|
|
628
|
+
scaleOnCpuUtilization?: number;
|
|
629
|
+
scaleOnMemoryUtilization?: number;
|
|
630
|
+
scaleOnRequestsPerTarget?: number;
|
|
631
|
+
scaleOnSchedule?: appAutoscaling.ScalingSchedule;
|
|
632
|
+
}
|
|
624
633
|
/**
|
|
625
634
|
* @category cdk-utils.ecs-manager
|
|
626
635
|
* @subcategory Properties
|
|
@@ -629,6 +638,7 @@ export interface EcsApplicationLoadBalancedFargateServiceProps extends ecsPatter
|
|
|
629
638
|
healthCheck?: HealthCheck;
|
|
630
639
|
logging?: ecs.AwsLogDriverProps;
|
|
631
640
|
mountPoints?: ecs.MountPoint[];
|
|
641
|
+
siteScaling?: EcsScalingProps;
|
|
632
642
|
}
|
|
633
643
|
/**
|
|
634
644
|
* @category cdk-utils.eks-manager
|
package/package.json
CHANGED
|
@@ -298,6 +298,36 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
298
298
|
|
|
299
299
|
fargateService.loadBalancer.logAccessLogs(this.siteLogBucket, 'alb')
|
|
300
300
|
|
|
301
|
+
if (this.props.siteTask.siteScaling) {
|
|
302
|
+
const scalableTaskCount = this.siteEcsService.autoScaleTaskCount({
|
|
303
|
+
minCapacity: this.props.siteTask.siteScaling.minCapacity,
|
|
304
|
+
maxCapacity: this.props.siteTask.siteScaling.maxCapacity ?? 4,
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
if (this.props.siteTask.siteScaling.scaleOnCpuUtilization) {
|
|
308
|
+
scalableTaskCount.scaleOnCpuUtilization(`${this.id}-cpu-scaling`, {
|
|
309
|
+
targetUtilizationPercent: this.props.siteTask.siteScaling.scaleOnCpuUtilization ?? 50,
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (this.props.siteTask.siteScaling.scaleOnMemoryUtilization) {
|
|
314
|
+
scalableTaskCount.scaleOnMemoryUtilization(`${this.id}-mem-scaling`, {
|
|
315
|
+
targetUtilizationPercent: this.props.siteTask.siteScaling.scaleOnMemoryUtilization ?? 50,
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (this.props.siteTask.siteScaling.scaleOnRequestsPerTarget) {
|
|
320
|
+
scalableTaskCount.scaleOnRequestCount(`${this.id}-req-count`, {
|
|
321
|
+
requestsPerTarget: this.props.siteTask.siteScaling.scaleOnRequestsPerTarget ?? 10000,
|
|
322
|
+
targetGroup: this.siteEcsTargetGroup,
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (this.props.siteTask.siteScaling.scaleOnSchedule) {
|
|
327
|
+
scalableTaskCount.scaleOnSchedule(`${this.id}-schedule`, this.props.siteTask.siteScaling.scaleOnSchedule)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
301
331
|
/* if enabled, add efs with access point and mount */
|
|
302
332
|
if (this.props.siteFileSystem) {
|
|
303
333
|
this.siteFileSystem = this.efsManager.createFileSystem(
|
|
@@ -28,6 +28,7 @@ import * as sfn from 'aws-cdk-lib/aws-stepfunctions'
|
|
|
28
28
|
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'
|
|
29
29
|
import * as wafv2 from 'aws-cdk-lib/aws-wafv2'
|
|
30
30
|
import * as types from '../index'
|
|
31
|
+
import * as appAutoscaling from 'aws-cdk-lib/aws-applicationautoscaling'
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* @category cdk-utils.app-config-manager
|
|
@@ -659,6 +660,15 @@ export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
|
659
660
|
logging?: ecs.AwsLogDriverProps
|
|
660
661
|
}
|
|
661
662
|
|
|
663
|
+
export interface EcsScalingProps {
|
|
664
|
+
minCapacity?: number
|
|
665
|
+
maxCapacity?: number
|
|
666
|
+
scaleOnCpuUtilization?: number
|
|
667
|
+
scaleOnMemoryUtilization?: number
|
|
668
|
+
scaleOnRequestsPerTarget?: number
|
|
669
|
+
scaleOnSchedule?: appAutoscaling.ScalingSchedule
|
|
670
|
+
}
|
|
671
|
+
|
|
662
672
|
/**
|
|
663
673
|
* @category cdk-utils.ecs-manager
|
|
664
674
|
* @subcategory Properties
|
|
@@ -668,6 +678,7 @@ export interface EcsApplicationLoadBalancedFargateServiceProps
|
|
|
668
678
|
healthCheck?: HealthCheck
|
|
669
679
|
logging?: ecs.AwsLogDriverProps
|
|
670
680
|
mountPoints?: ecs.MountPoint[]
|
|
681
|
+
siteScaling?: EcsScalingProps
|
|
671
682
|
}
|
|
672
683
|
|
|
673
684
|
/**
|