AWS | Cleaning up your Amazon ECS resources

In my previous blog posts on AWS (Introduction to Amazon ECS | Launch Amazon ECS cluster | Scaling with Amazon ECS | Deploy updated Task definition/Docker image), I had given an overview about what is Amazon ECS with a walk-through on how to launch Amazon ECS and then deploy sample app by creating a task definition, scheduling tasks and configuring a cluster and to scale in / scale out the same on Amazon ECS and we have also gained the knowledge on how to create a new revision for the existing task definition to deploy the latest updated docker image.

In this we will have a look on cleaning up your Amazon ECS resources that we have created so far. Once you have launched the Amazon ECS cluster and try to terminate container instances in order to clean up the resources then you won’t be able to do so because of cloud formation.

Below are the step that you have to follow in order to clean up Amazon ECS recourses :

1. Scale Down Services :  Firstly, we have to scale down the desired count of tasks to ‘0’ of all the services running in a cluster, so that Amazon ECS does not try to start new tasks on our container instances while we are cleaning up.

1-copy

1.png

2. Delete Services : Then we must delete the same services inside that cluster. After our service has scaled down to ‘0’ task, we can delete it. But if you try to delete the service before scaling it down to ‘0’ then Amazon ECS won’t let you do so.

2

3. De-register Task Definitions : Under Task definition navigation pane, select all the revision of a definition that you want to clean up and click on De-register.

3

4. De-register Container Instances : Before we can delete a cluster, we must De-register the container instances inside that cluster. For each container instance inside our cluster, follow the procedures in De-register a Container Instance to De-register it.

4

5.png

5. Delete a Cluster : Finally, we have removed the active resources from our Amazon ECS cluster, then go to Clusters navigation pane and delete the cluster by clicking on ‘Delete cluster’ button.

6.png

7

This will clean up your cluster recourses.

I hope through these series of blog, you will be able to launch Amazon ECS cluster and deploy your application in container environment and easily able to scale in/ scale out the tasks and container instances.

If you have any question/concerns, please feel free to ask. I’ll be more than happy to help you. 🙂

Thanks


KNOLDUS-advt-sticker

4 thoughts on “AWS | Cleaning up your Amazon ECS resources

Leave a Reply

%d bloggers like this: