We are trying to create a service with the specified task definition using the create-service command of aws ecs cli. Our task definition is 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]}"
The command mentions that it can take multiple load balancers as input but when we provide them in comma separated format only the last one is taken into account.
In this case only one that is attached to app2 container is published in the output. Need help on this how to provide multiple load balancer information in the cli command.
You can add JSON to any AWS CLI command.
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 \
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With