问题描述
我正在尝试基于CloudWatch Alarm(名称空间-AWS / SQS,指标名称-近似NumberOfMessagesVisible)在AWS ECS中自动缩放Fargate服务。我设法在AWS控制台中做到了这一点,但没有通过代码(在Pulumi中)完成。
我对代码的建议如下:
const vpc = new awsx.ec2.Vpc("vpc",{
subnets: [{ type: "public" }],});
const my_cluster = new awsx.ecs.Cluster("my-cluster",{ vpc });
const task = new awsx.ecs.FargateTaskDeFinition(...)
const my_fargateService = new awsx.ecs.FargateService(
"my-fargateService",{
cluster: my_cluster,taskDeFinition: task,desiredCount: 0,}
);
const sqs_queue = new aws.sqs.Queue(
"fargateServiceQueque"
);
const autoscaling_Policy1 = new aws.autoscaling.Policy("autoscaling_Policy1",{
policyType: "StepScaling",adjustmentType: "ExactCapacity",stepAdjustments: [{
metricIntervalUpperBound: 1,scalingAdjustment: 0
}],// I think problem here
autoscalingGroupName: autoScalingGroupFromFargateService.name // ???
});
const sqs_less_than_1 = new aws.cloudwatch.MetricAlarm("sqs_less_than_1_message_visible",{
comparisonoperator: "LessthanThreshold",evaluationPeriods: "2",metricName: "approximateNumberOfMessagesVisible",namespace: "AWS/SQS",period: "120",statistic: "Maximum",threshold: "1",dimensions: {
QueueName: sqs_queue.name,},alarmDescription: "This metric monitors number of messages in sqs queue",alarmActions: [] // I think it should be -> [autoscaling_Policy1.arn],});
问题-我不知道如何从my_fargateService检索自动缩放组(“ autoScalingGroupFromFargateService.name”)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)