Amazon Web Services (AWS) Elastic Container Service (ECS) - Delete Services using the AWS CLI
by
Jeremy Canfield |
Updated: October 23 2023
| Amazon Web Services (AWS) Elastic Container Service (ECS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
The aws ecs list-clusters command can be used to list your Elastic Container Service (ECS) Clusters.
~]$ aws ecs list-clusters
{
"clusterArns": [
"arn:aws:ecs:us-east-1:123456789012:cluster/my-ecs-cluster"
]
}
And then the aws ecs list-services command can be used to list the services that have been created in the cluster.
]$ aws ecs list-services --cluster arn:aws:ecs:us-east-1:123456789012:cluster/my-ecs-cluster
{
"serviceArns": [
"arn:aws:ecs:us-east-1:123456789012:service/my-ecs-cluster/nginx-service"
]
}
And then the aws ecs update-service command can be used to update the desired count of containers for the service down to 0.
aws ecs update-service \
--cluster arn:aws:ecs:us-east-1:123456789012:cluster/my-ecs-cluster \
--service arn:aws:ecs:us-east-1:123456789012:service/my-ecs-cluster/nginx-service \
--desired-count 0
And then the aws ecs delete-service command can be used to delete a service that has been scaled down to zero.
aws ecs delete-service \
--cluster arn:aws:ecs:us-east-1:123456789012:cluster/my-ecs-cluster \
--service arn:aws:ecs:us-east-1:123456789012:service/my-ecs-cluster/nginx-service
Did you find this article helpful?
If so, consider buying me a coffee over at