class ScalableTaskCount (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ECS.ScalableTaskCount |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#ScalableTaskCount |
Java | software.amazon.awscdk.services.ecs.ScalableTaskCount |
Python | aws_cdk.aws_ecs.ScalableTaskCount |
TypeScript (source) | aws-cdk-lib » aws_ecs » ScalableTaskCount |
Implements
IConstruct, IDependable, IScalable, IEnvironment
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"),
},
minHealthyPercent: 100,
});
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 |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| node | Node | The tree node. |
| scalable | Scalable | A reference to a ScalableTarget resource. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
node
Type:
Node
The tree node.
scalableTargetRef
Type:
Scalable
A reference to a ScalableTarget resource.
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
Go
Java
Python
TypeScript (