Amazon Elastic Container Service
Developer Guide (API Version 2014-11-13)

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.

To delete an Amazon ECS service

Use the following procedure to delete an Amazon ECS service.

  1. Open the Amazon ECS console at https://console.aws.amazon.com/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.

To delete the service discovery resources (AWS CLI)

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

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

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

    aws servicediscovery list-services --region <region_name>
  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>