Deleting a service - Amazon Elastic Container Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Deleting a service

You can delete an Amazon ECS service using the console. Before deletion, the service is automatically scaled down to zero. If you have a load balancer or service discovery resources associated with the service, they are not affected by the service deletion. To delete your Elastic Load Balancing resources, see one of the following topics, depending on your load balancer type: Delete an Application Load Balancer or Delete a Network Load Balancer. To delete your service discovery resources, follow the procedure below.

Classic console

Use the following procedure to delete an Amazon ECS service.

  1. Open the Amazon ECS console at https://console.amazonaws.cn/ecs/.

  2. On the navigation bar, select the Region that your cluster is in.

  3. In the navigation pane, choose Clusters and select the name of the cluster in which your service resides.

  4. On the Cluster : name page, choose Services.

  5. Check the box to the left of the service to update and choose Delete.

  6. Confirm the service deletion by entering the text phrase and choose Delete.

Amazon CLI

To delete the remaining service discovery resources, you can use the Amazon CLI to delete the service discovery service and service discovery namespace.

  1. Ensure that the latest version of the Amazon CLI is installed and configured. For more information about installing or upgrading your Amazon CLI, see Installing the Amazon Command Line Interface.

  2. Retrieve the ID of the service discovery service to delete.

    aws servicediscovery list-services --region <region_name>
    Note

    If no service discovery service is returned, continue to step 4.

  3. Using the service discovery service ID from the previous output, delete the service.

    aws servicediscovery delete-service --id <service_discovery_service_id> --region <region_name>
  4. Retrieve the ID of the service discovery namespace to delete.

    aws servicediscovery list-namespaces --region <region_name>
  5. Using the service discovery namespace ID from the previous output, delete the namespace.

    aws servicediscovery delete-namespace --id <service_discovery_namespace_id> --region <region_name>