AWS ECS Fargate:如何使用服务 API 创建具有自动扩展功能的服务

AWS ECS Fargate: How to create a service with auto scaling with the service API

我不明白如何使用 API 为 ecs fargate 服务创建自动缩放。我用这样的代码和 ecs create service api:

创建我的服务
{    
    "serviceName": "my-service",
    "cluster": "my-cluster",
    "taskDefinition": "my-task",
    "desiredCount": 1,
    "launchType": "FARGATE",
    "loadBalancers":[
        {
            "targetGroupArn": my_target_group_arn,
            "containerName": "my-container-nginx",
            "containerPort": 8090
        }        
    ],
    "networkConfiguration": {
        'awsvpcConfiguration': {
            'subnets': settings.AWS_SUBNET_IDS,
            'securityGroups': [securitygroup_id]
        }
    },   

}

如何添加自动缩放,我可以在浏览器的 AWS 控制台中轻松配置?我必须创建 capacityProvider 吗?

This documentation 向您介绍如何通过 CLI 为 ECS 配置服务自动扩展策略。请注意,控制台通常会提供“宏”体验,使所有步骤更容易,而如果您必须对 CLI/API 执行相同的操作,则通常需要多个步骤(如文档中所述)。