class ScalableTaskCount (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ECS.ScalableTaskCount |
Java | software.amazon.awscdk.services.ecs.ScalableTaskCount |
Python | aws_cdk.aws_ecs.ScalableTaskCount |
TypeScript (source) | @aws-cdk/aws-ecs » ScalableTaskCount |
Implements
IConstruct, IConstruct, IDependable
The scalable attribute representing task count.
Example
declare const cluster: ecs.Cluster;
const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
cluster,
memoryLimitMiB: 1024,
desiredCount: 1,
cpu: 512,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
},
});
const scalableTarget = loadBalancedFargateService.service.autoScaleTaskCount({
minCapacity: 1,
maxCapacity: 20,
});
scalableTarget.scaleOnCpuUtilization('CpuScaling', {
targetUtilizationPercent: 50,
});
scalableTarget.scaleOnMemoryUtilization('MemoryScaling', {
targetUtilizationPercent: 50,
});
Initializer
new ScalableTaskCount(scope: Construct, id: string, props: ScalableTaskCountProps)
Parameters
- scope
Construct - id
string - props
ScalableTask Count Props
Constructs a new instance of the ScalableTaskCount class.
Construct Props
| Name | Type | Description |
|---|---|---|
| dimension | string | Scalable dimension of the attribute. |
| max | number | Maximum capacity to scale to. |
| resource | string | Resource ID of the attribute. |
| role | IRole | Role to use for scaling. |
| service | Service | Service namespace of the scalable attribute. |
| min | number | Minimum capacity to scale to. |
dimension
Type:
string
Scalable dimension of the attribute.
maxCapacity
Type:
number
Maximum capacity to scale to.
resourceId
Type:
string
Resource ID of the attribute.
role
Type:
IRole
Role to use for scaling.
serviceNamespace
Type:
Service
Service namespace of the scalable attribute.
minCapacity?
Type:
number
(optional, default: 1)
Minimum capacity to scale to.
Properties
| Name | Type | Description |
|---|---|---|
| node | Construct | The construct tree node associated with this construct. |
node
Type:
Construct
The construct tree node associated with this construct.
Methods
| Name | Description |
|---|---|
| scale | Scales in or out to achieve a target CPU utilization. |
| scale | Scales in or out to achieve a target memory utilization. |
| scale | Scales in or out based on a specified metric value. |
| scale | Scales in or out to achieve a target Application Load Balancer request count per target. |
| scale | Scales in or out based on a specified scheduled time. |
| scale | Scales in or out to achieve a target on a custom metric. |
| to | Returns a string representation of this construct. |
scaleOnCpuUtilization(id, props)
public scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps): void
Parameters
- id
string - props
CpuUtilization Scaling Props
Scales in or out to achieve a target CPU utilization.
scaleOnMemoryUtilization(id, props)
public scaleOnMemoryUtilization(id: string, props: MemoryUtilizationScalingProps): void
Parameters
- id
string - props
MemoryUtilization Scaling Props
Scales in or out to achieve a target memory utilization.
scaleOnMetric(id, props)
public scaleOnMetric(id: string, props: BasicStepScalingPolicyProps): void
Parameters
- id
string - props
BasicStep Scaling Policy Props
Scales in or out based on a specified metric value.
scaleOnRequestCount(id, props)
public scaleOnRequestCount(id: string, props: RequestCountScalingProps): void
Parameters
- id
string - props
RequestCount Scaling Props
Scales in or out to achieve a target Application Load Balancer request count per target.
scaleOnSchedule(id, props)
public scaleOnSchedule(id: string, props: ScalingSchedule): void
Parameters
- id
string - props
ScalingSchedule
Scales in or out based on a specified scheduled time.
scaleToTrackCustomMetric(id, props)
public scaleToTrackCustomMetric(id: string, props: TrackCustomMetricProps): void
Parameters
- id
string - props
TrackCustom Metric Props
Scales in or out to achieve a target on a custom metric.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.

.NET
Java
Python
TypeScript (