AWS.ApplicationAutoScaling reference
DescribeScalingActivities
Section titled “DescribeScalingActivities”Source:
src/AWS/ApplicationAutoScaling/DescribeScalingActivities.ts
Runtime binding for the DescribeScalingActivities operation (IAM action
application-autoscaling:DescribeScalingActivities).
Returns the scalable target’s scaling activities from the previous six
weeks — what scaled, when, why, and whether it succeeded — including
not-scaled reasons when IncludeNotScaledActivities is set. Provide the
implementation with
Effect.provide(AWS.ApplicationAutoScaling.DescribeScalingActivitiesHttp).
DescribeScalingActivities: Observing Scaling Activity
Section titled “DescribeScalingActivities: Observing Scaling Activity”List Recent Scaling Activities
// init — bind the operation to the scalable targetconst describeScalingActivities = yield* AWS.ApplicationAutoScaling.DescribeScalingActivities(target);
// runtime — page through the target's recent activitiesconst page = yield* describeScalingActivities({ MaxResults: 50 });for (const activity of page.ScalingActivities ?? []) { yield* Effect.log(`${activity.StatusCode}: ${activity.Description}`);}Include Not-Scaled Reasons
const page = yield* describeScalingActivities({ IncludeNotScaledActivities: true,});GetPredictiveScalingForecast
Section titled “GetPredictiveScalingForecast”Source:
src/AWS/ApplicationAutoScaling/GetPredictiveScalingForecast.ts
Runtime binding for the GetPredictiveScalingForecast operation (IAM
action application-autoscaling:GetPredictiveScalingForecast).
Retrieves the load and capacity forecast a predictive scaling policy has
computed for a time window (forecasts are created from at least 24 hours of
historical CloudWatch data). The bound policy must be a PredictiveScaling
policy on an ECS service: the API rejects other policy types with the typed
ValidationException and namespaces without predictive scaling support
with the typed PredictiveScalingForecastNotSupported. Provide the
implementation with
Effect.provide(AWS.ApplicationAutoScaling.GetPredictiveScalingForecastHttp).
GetPredictiveScalingForecast: Reading Forecasts
Section titled “GetPredictiveScalingForecast: Reading Forecasts”// init — bind the operation to the predictive scaling policyconst getPredictiveScalingForecast = yield* AWS.ApplicationAutoScaling.GetPredictiveScalingForecast(policy);
// runtime — read the forecast windowconst now = yield* Effect.sync(() => Date.now());const forecast = yield* getPredictiveScalingForecast({ StartTime: new Date(now), EndTime: new Date(now + 48 * 60 * 60 * 1000),});const capacity = forecast.CapacityForecast?.Values ?? [];ScalableTarget
Section titled “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.
ScalableTarget: Creating Scalable Targets
Section titled “ScalableTarget: 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,});ScalableTarget: Suspending Scaling
Section titled “ScalableTarget: 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 },});ScalingPolicy
Section titled “ScalingPolicy”Source:
src/AWS/ApplicationAutoScaling/ScalingPolicy.ts
An Application Auto Scaling scaling policy attached to a scalable target.
Supports TargetTrackingScaling (Application Auto Scaling creates and
manages the CloudWatch alarms) and StepScaling (you attach the policy to
your own alarm). The policy applies to the scalable target identified by
the (serviceNamespace, resourceId, scalableDimension) triple, which
must be registered (see ScalableTarget) before the policy is
created — pass the target’s outputs so deployment orders correctly.
ScalingPolicy: Target Tracking
Section titled “ScalingPolicy: Target Tracking”Track ECS Service CPU
const target = yield* ScalableTarget("ApiScaling", { serviceNamespace: "ecs", resourceId: Output.interpolate`service/${cluster.clusterName}/${service.serviceName}`, scalableDimension: "ecs:service:DesiredCount", minCapacity: 1, maxCapacity: 3,});
yield* ScalingPolicy("ApiCpuPolicy", { serviceNamespace: target.serviceNamespace, resourceId: target.resourceId, scalableDimension: target.scalableDimension, targetTracking: { TargetValue: 60, PredefinedMetricSpecification: { PredefinedMetricType: "ECSServiceAverageCPUUtilization", }, ScaleOutCooldown: 60, ScaleInCooldown: 60, },});Track a Customized Metric
yield* ScalingPolicy("QueueDepthPolicy", { serviceNamespace: target.serviceNamespace, resourceId: target.resourceId, scalableDimension: target.scalableDimension, targetTracking: { TargetValue: 100, CustomizedMetricSpecification: { MetricName: "ApproximateNumberOfMessagesVisible", Namespace: "AWS/SQS", Dimensions: [{ Name: "QueueName", Value: "my-queue" }], Statistic: "Average", }, },});ScalingPolicy: Step Scaling
Section titled “ScalingPolicy: Step Scaling”yield* ScalingPolicy("ApiStepPolicy", { serviceNamespace: target.serviceNamespace, resourceId: target.resourceId, scalableDimension: target.scalableDimension, stepScaling: { AdjustmentType: "ChangeInCapacity", Cooldown: 60, MetricAggregationType: "Average", StepAdjustments: [ { MetricIntervalLowerBound: 0, ScalingAdjustment: 1 }, ], },});ScheduledAction
Section titled “ScheduledAction”Source:
src/AWS/ApplicationAutoScaling/ScheduledAction.ts
An Application Auto Scaling scheduled action — adjusts a scalable target’s
minimum and/or maximum capacity on a one-time (at(...)) or recurring
(cron(...) / rate(...)) schedule.
The action applies to the scalable target identified by the
(serviceNamespace, resourceId, scalableDimension) triple, which must
be registered (see ScalableTarget) before the action is created —
pass the target’s outputs so deployment orders correctly.
ScheduledAction: Scheduling Capacity Changes
Section titled “ScheduledAction: Scheduling Capacity Changes”Scale Out for Business Hours
yield* ScheduledAction("BusinessHoursScaleOut", { serviceNamespace: target.serviceNamespace, resourceId: target.resourceId, scalableDimension: target.scalableDimension, schedule: "cron(0 8 ? * MON-FRI *)", timezone: "America/Los_Angeles", scalableTargetAction: { MinCapacity: 3, MaxCapacity: 10 },});One-Time Capacity Bump
yield* ScheduledAction("LaunchDayBump", { serviceNamespace: target.serviceNamespace, resourceId: target.resourceId, scalableDimension: target.scalableDimension, schedule: "at(2030-01-01T00:00:00)", scalableTargetAction: { MinCapacity: 5 },});