AWS creation failed: Service already exists. (Service: AWSServiceDiscovery; Status Code: 400; Error Code: ServiceAlreadyExists; Request ID)

前端 未结 2 1050
被撕碎了的回忆
被撕碎了的回忆 2021-02-02 00:00

i am new to aws and encountred some problem while trying to create a EC2 service in a ECS cluster.

i was able to successfully create a brand new service (service1) in cl

2条回答
  •  不知归路
    2021-02-02 00:45

    Here is full answer. When you created AWS ECS Service and you have also selected optional ServiceDiscovery for it as well which created an namespace(.local) and service(with same name as ECS Service) in Route53.

    When you deleted ECS service & cluster, it won't automatically delete Route53 namespace/service entries. Now, you are getting Service already exists error since your new ECS Service matches with same name as ServiceDiscovery service. You have 3 options. 1. Clean up Route53 namespaces and services. 2. Re-use Route53 Service if you want to continue to use ServiceDiscovery feature. 3. Don't enable service discovery integration when you are creating ECS Service.

    Option 1 -

    • You cannot delete Route53 ServiceDiscovery namespaces and service via Console. You will need to use AWS CLI.(Make sure you have configured CLI with AWS Keys same as the account where you have created ECS) https://docs.aws.amazon.com/cli/latest/reference/servicediscovery/index.html
    • List the Namespaces & Services with CLI using following commands and sample output you should get.
    • aws servicediscovery list-services

    { "Services": [ { "Id": "srv-x4acveybedar32mv", "Arn": "arn:aws:servicediscovery:us-east-1:1234567890:service/srv-x4acveybedar32mv", "Name": "nginx" } ] }

    • aws servicediscovery list-namespaces

    { "Namespaces": [ { "Id": "ns-3yd7pskwsxhwlq67", "Arn": "arn:aws:servicediscovery:us-east-1:1234567890:namespace/ns-3yd7pskwsxhwlq67", "Name": "local", "Type": "DNS_PRIVATE" } ] }

    • Delete the Service first with command. aws servicediscovery delete-service --id "srv-x4acveybedar32mv" . Result is empty response from CLI.
    • Delete the namespace with command. aws servicediscovery delete-namespace --id "ns-3yd7pskwsxhwlq67"

    { "OperationId": "s573v5dr62yee5d7vbfvsy5h65ybxmoh-jossalgs" }

    • That's all. Now, you can re-create ECS services which you wanted.

    Note -

    Sometimes, DNS cleanup operations will take couple of minutes to reflect properly so just give always few minutes before retrying.

    Option 2 -

    • Re-use Route53 Services by selecting exiting one instead of creating with same name.

提交回复
热议问题