ScalableTarget
Source:
src/AWS/ApplicationAutoScaling/ScalableTarget.ts
An Application Auto Scaling scalable target — registers a resource’s capacity dimension (an ECS service’s desired count, a DynamoDB table’s read capacity, Lambda provisioned concurrency, …) so that scaling policies and scheduled actions can act on it.
A scalable target is uniquely identified by the
(serviceNamespace, resourceId, scalableDimension) triple; changing
any part of the triple replaces the target. Deregistering a scalable
target deletes the scaling policies and scheduled actions associated
with it.
Creating Scalable Targets
Section titled “Creating Scalable Targets”Scale an ECS Service
const target = yield* ScalableTarget("ApiScaling", { serviceNamespace: "ecs", resourceId: Output.interpolate`service/${cluster.clusterName}/${service.serviceName}`, scalableDimension: "ecs:service:DesiredCount", minCapacity: 1, maxCapacity: 3,});Scale DynamoDB Read Capacity
const target = yield* ScalableTarget("TableReadScaling", { serviceNamespace: "dynamodb", resourceId: Output.interpolate`table/${table.tableName}`, scalableDimension: "dynamodb:table:ReadCapacityUnits", minCapacity: 1, maxCapacity: 10,});Suspending Scaling
Section titled “Suspending Scaling”yield* ScalableTarget("ApiScaling", { serviceNamespace: "ecs", resourceId: Output.interpolate`service/${cluster.clusterName}/${service.serviceName}`, scalableDimension: "ecs:service:DesiredCount", minCapacity: 1, maxCapacity: 3, suspendedState: { DynamicScalingInSuspended: true },});