Hey Folks, I'm looking for an example/doc to autos...
# aws
s
Hey Folks, I'm looking for an example/doc to autoscale
ECS Fargate services
through
CloudWatch
Alarms based on the
CPU-Utilization/Memory-Consumption
@witty-candle-66007 👀
w
Although I haven’t tried it myself, it appears that the appautoscaling resource is what you would use to set this up: https://www.pulumi.com/registry/packages/aws/api-docs/appautoscaling/
In Typescript something like this:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const devToTarget = new aws.appautoscaling.Target("devToTarget", {
    maxCapacity: 5,
    minCapacity: 1,
    resourceId: `service/${_var.ecs_cluster.name}/${_var.ecs_service.name}`,
    scalableDimension: "ecs:service:DesiredCount",
    serviceNamespace: "ecs",
});
const devToMemory = new aws.appautoscaling.Policy("devToMemory", {
    policyType: "TargetTrackingScaling",
    resourceId: devToTarget.resourceId,
    scalableDimension: devToTarget.scalableDimension,
    serviceNamespace: devToTarget.serviceNamespace,
    targetTrackingScalingPolicyConfiguration: {
        predefinedMetricSpecification: {
            predefinedMetricType: "ECSServiceAverageMemoryUtilization",
        },
        targetValue: 80,
    },
});
const devToCpu = new aws.appautoscaling.Policy("devToCpu", {
    policyType: "TargetTrackingScaling",
    resourceId: devToTarget.resourceId,
    scalableDimension: devToTarget.scalableDimension,
    serviceNamespace: devToTarget.serviceNamespace,
    targetTrackingScalingPolicyConfiguration: {
        predefinedMetricSpecification: {
            predefinedMetricType: "ECSServiceAverageCPUUtilization",
        },
        targetValue: 60,
    },
});
❤️ 1
s
I've started implementing the appautoscaling, but I got stuck at the CPU/memory consumption...I didn't know how to specify the thresholds... Thanks a lot 🙏 your example will surely help unblock me