我们正在尝试使用aws ecs cli的create-service命令创建具有指定任务定义的服务。我们的任务定义是people-cloud:27。
aws ecs create-service --cluster cloud1 --service-name docker-service --task-definition people-cloud:27
--load-balancers targetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:2******5555:targetgroup/ecsCloud/ee7f4c280b1672aa,containerName=app,containerPort=8080,targetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:2******5555:targetgroup/ecsServer/54fcbf7052957660,containerName=app2,containerPort=2990
--launch-type FARGATE --client-token AMOEBA@123 --desired-count 1 --network-configuration "awsvpcConfiguration={subnets=[subnet-0e11****f9e4218,subnet-0er****ufgrger],securityGroups=[sg-******5b***b3]}"
该命令提到它可以将多个负载均衡器作为输入,但是当我们以逗号分隔的格式提供它们时,仅考虑最后一个。
在这种情况下,输出中仅发布附加到app2容器的容器。在cli命令中如何提供多个负载均衡器信息方面需要帮助。
答案 0 :(得分:1)
您可以将 JSON 添加到任何 AWS CLI 命令。
aws ecs create-service --cluster mycluster \
--cli-input-json '{"loadBalancers": [
{
"targetGroupArn": "my_target1_arn",
"containerName": "mycontainer",
"containerPort": 8080
},
{
"targetGroupArn": "my_target2_arn",
"containerName": "mycontainer",
"containerPort": 80
}
]}' \
--service-name myservice \
...
答案 1 :(得分:0)
尝试不添加逗号。文档说--load-balancers
是list
aws ecs create-service --cluster cloud1 --service-name docker-service --task-definition people-cloud:27
--load-balancers targetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:2******5555:targetgroup/ecsCloud/ee7f4c280b1672aa,containerName=app,containerPort=8080 targetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:2******5555:targetgroup/ecsServer/54fcbf7052957660,containerName=app2,containerPort=2990
--launch-type FARGATE --client-token AMOEBA@123 --desired-count 1 --network-configuration "awsvpcConfiguration={subnets=[subnet-0e11****f9e4218,subnet-0er****ufgrger],securityGroups=[sg-******5b***b3]}"
上的文档