Amazon-ecs-agent: Unable to create ECS Service with ELB in cli

Created on 28 Dec 2016  路  7Comments  路  Source: aws/amazon-ecs-agent

Hello,

I am trying to create ECS service for existing task definition and ELB, but I am unable create PFB for more info.

$ aws ecs create-service --cluster mytestnode --service-name my-test-node-service --task-definition mytestnode --load-balancers loadBalancerName=mytestnodejs,containerName=mytestnode,containerPort=4000 --role ecsServiceRole --desired-count 0

An error occurred (InvalidParameterException) when calling the CreateService operation: The load balancer mytestnodejs does not exist.

Kindly someone suggest what was wrong in the above command.

Regards,
Raja

Most helpful comment

Check the documentation on the --load-balancers option on http://docs.aws.amazon.com/cli/latest/reference/ecs/create-service.html.

For ALB you need to include the targetGroupArn.

For example:

targetGroupArn=string,containerName=string,containerPort=integer

All 7 comments

The error is indicating that the load balancer you're trying to use does not exist in the account/region combination you're operating in. You may wish to double check with a command like aws elb describe-load-balancers --load-balancer-name mytestnodejs that the ELB exists. It may be that you created it in a different region from the one you're currently operating in.

Thanks for your feed back.. I was using application load balancer. I can describe my application load balancer by following command.

aws elbv2 describe-load-balancers --load-balancer-arns arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188

Kindly let me know how to add application loadbalancer in my service.

Regards,
Raja

Thanks for your input... I done this step be following below command.

aws ecs create-service --cluster mytestnode --service-name my-green-node-service --task-definition mytestnode:11 --targetGroupArn=arn:aws:elasticloadbalancing:us-east-1:855158544446:targetgroup/mytestnodejs/b3ca155a15448abe loadBalancerName=mytestnodejs containerName=mytestnode containerPort=4000 --desired-count 1

Regards,
Raja

got the same problem, @rajasekaran07 have you find the solution?

Check the documentation on the --load-balancers option on http://docs.aws.amazon.com/cli/latest/reference/ecs/create-service.html.

For ALB you need to include the targetGroupArn.

For example:

targetGroupArn=string,containerName=string,containerPort=integer

To expand on @joost - you also need to remove the LoadBalancerName if you're using an application load balancer, and just use the TargetGroupArn instead. (The load balancer name is only for classic load balancers).

The target group should have a load balancer listener created already which links the load balancer to the target group.

If you're having issues with CloudFormation, make sure your ECS service depends on that listener being created.

Was this page helpful?
0 / 5 - 0 ratings