aws-cdk-lib.aws_ecs.ScalableTaskCount

class ScalableTaskCount (construct)

LanguageType name
.NETAmazon.CDK.AWS.ECS.ScalableTaskCount
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#ScalableTaskCount
Javasoftware.amazon.awscdk.services.ecs.ScalableTaskCount
Pythonaws_cdk.aws_ecs.ScalableTaskCount
TypeScript (source)aws-cdk-lib » aws_ecs » ScalableTaskCount

Implements 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 ScalableTaskCountProps

Constructs a new instance of the ScalableTaskCount class.

Construct Props

NameTypeDescription
dimensionstringScalable dimension of the attribute.
maxCapacitynumberMaximum capacity to scale to.
resourceIdstringResource ID of the attribute.
roleIRoleRole to use for scaling.
serviceNamespaceServiceNamespaceService namespace of the scalable attribute.
minCapacity?numberMinimum 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: ServiceNamespace

Service namespace of the scalable attribute.


minCapacity?

Type: number (optional, default: 1)

Minimum capacity to scale to.

Properties

NameTypeDescription
nodeNodeThe tree node.

node

Type: Node

The tree node.

Methods

NameDescription
scaleOnCpuUtilization(id, props)Scales in or out to achieve a target CPU utilization.
scaleOnMemoryUtilization(id, props)Scales in or out to achieve a target memory utilization.
scaleOnMetric(id, props)Scales in or out based on a specified metric value.
scaleOnRequestCount(id, props)Scales in or out to achieve a target Application Load Balancer request count per target.
scaleOnSchedule(id, props)Scales in or out based on a specified scheduled time.
scaleToTrackCustomMetric(id, props)Scales in or out to achieve a target on a custom metric.
toString()Returns a string representation of this construct.

scaleOnCpuUtilization(id, props)

public scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps): void

Parameters

  • id string
  • props CpuUtilizationScalingProps

Scales in or out to achieve a target CPU utilization.


scaleOnMemoryUtilization(id, props)

public scaleOnMemoryUtilization(id: string, props: MemoryUtilizationScalingProps): void

Parameters

  • id string
  • props MemoryUtilizationScalingProps

Scales in or out to achieve a target memory utilization.


scaleOnMetric(id, props)

public scaleOnMetric(id: string, props: BasicStepScalingPolicyProps): void

Parameters

  • id string
  • props BasicStepScalingPolicyProps

Scales in or out based on a specified metric value.


scaleOnRequestCount(id, props)

public scaleOnRequestCount(id: string, props: RequestCountScalingProps): void

Parameters

  • id string
  • props RequestCountScalingProps

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 TrackCustomMetricProps

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.