@gradientedge/cdk-utils 8.40.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);
|
|
@@ -287,6 +312,13 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
287
312
|
authorizationConfig: this.props.siteFileSystem.authorizationConfig,
|
|
288
313
|
},
|
|
289
314
|
});
|
|
315
|
+
if (this.props.siteTask.mountPoints && this.props.siteTask.mountPoints.length > 0) {
|
|
316
|
+
this.props.siteTask.mountPoints.forEach(mountPoint => this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
317
|
+
containerPath: mountPoint.containerPath,
|
|
318
|
+
readOnly: mountPoint.readOnly,
|
|
319
|
+
sourceVolume: `${this.id}-fs`,
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
290
322
|
}
|
|
291
323
|
this.addCfnOutput(`${this.id}-loadBalancerArn`, this.siteEcsLoadBalancer.loadBalancerArn ?? '');
|
|
292
324
|
this.addCfnOutput(`${this.id}-loadBalancerName`, this.siteEcsLoadBalancer.loadBalancerName ?? '');
|
|
@@ -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
|
|
@@ -628,6 +637,8 @@ export interface EcsTaskProps extends ecs.TaskDefinitionProps {
|
|
|
628
637
|
export interface EcsApplicationLoadBalancedFargateServiceProps extends ecsPatterns.ApplicationLoadBalancedFargateServiceProps {
|
|
629
638
|
healthCheck?: HealthCheck;
|
|
630
639
|
logging?: ecs.AwsLogDriverProps;
|
|
640
|
+
mountPoints?: ecs.MountPoint[];
|
|
641
|
+
siteScaling?: EcsScalingProps;
|
|
631
642
|
}
|
|
632
643
|
/**
|
|
633
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(
|
|
@@ -322,6 +352,16 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
322
352
|
authorizationConfig: this.props.siteFileSystem.authorizationConfig,
|
|
323
353
|
},
|
|
324
354
|
})
|
|
355
|
+
|
|
356
|
+
if (this.props.siteTask.mountPoints && this.props.siteTask.mountPoints.length > 0) {
|
|
357
|
+
this.props.siteTask.mountPoints.forEach(mountPoint =>
|
|
358
|
+
this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
359
|
+
containerPath: mountPoint.containerPath,
|
|
360
|
+
readOnly: mountPoint.readOnly,
|
|
361
|
+
sourceVolume: `${this.id}-fs`,
|
|
362
|
+
})
|
|
363
|
+
)
|
|
364
|
+
}
|
|
325
365
|
}
|
|
326
366
|
|
|
327
367
|
this.addCfnOutput(`${this.id}-loadBalancerArn`, this.siteEcsLoadBalancer.loadBalancerArn ?? '')
|
|
@@ -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
|
|
@@ -667,6 +677,8 @@ export interface EcsApplicationLoadBalancedFargateServiceProps
|
|
|
667
677
|
extends ecsPatterns.ApplicationLoadBalancedFargateServiceProps {
|
|
668
678
|
healthCheck?: HealthCheck
|
|
669
679
|
logging?: ecs.AwsLogDriverProps
|
|
680
|
+
mountPoints?: ecs.MountPoint[]
|
|
681
|
+
siteScaling?: EcsScalingProps
|
|
670
682
|
}
|
|
671
683
|
|
|
672
684
|
/**
|