如何解决如何在Pulumi中使用逐步扩展策略设置Fargate服务自动扩展?
我正在尝试基于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 举报,一经查实,本站将立刻删除。