← Back to list

Cleaning Up Orphaned ECS Capacity Providers in AWS

When managing resources on AWS, sometimes things don’t go as planned. One common situation is when an Amazon ECS (Elastic Container…

ismail yenigül in FAUN.dev() 🐾 · 2025-04-18 19:06 · 1 claps · 2.4 min read
#ec #aws #capacity-provider #aws-auto-scaling
Open on Medium ↗
Wiki topics: GEN · Genomics & Sequencing ☁️ · DevOps & Cloud

Cleaning Up Orphaned ECS Capacity Providers in AWS

When managing resources on AWS, sometimes things don’t go as planned. One common situation is when an Amazon ECS (Elastic Container Service) cluster is deleted, but the associated capacity provider settings are left behind. This can create confusion, as the capacity provider will still appear in the AWS CLI but won’t be associated with any existing ECS cluster, making it impossible to manage from the ECS dashboard.

In this post, we’ll walk through how to clean up orphaned ECS capacity providers that are left behind when an ECS cluster is deleted.

What Is an ECS Capacity Provider?

An ECS capacity provider is a resource that allows ECS to manage the underlying infrastructure (like EC2 instances) for your containerized applications. It defines how Amazon ECS provisions and manages compute resources (EC2 instances) to run ECS tasks.

When you create an ECS cluster, you can configure it with one or more capacity providers. These providers are linked to autoscaling groups, which scale the EC2 instances based on your workload’s requirements.

The Problem

In some cases, you may notice that even after deleting an ECS cluster, the associated capacity provider still exists. It might appear in the AWS CLI as an active capacity provider, but it won’t show up in the ECS dashboard. This can be confusing, and the capacity provider might be unmanageable. When you try to attach an ASG to ECS cluster with no capacityProvider is configured, you might get the following error

The specified Auto Scaling group ARN is already being used by another capacity provider. 
Specify a unique Auto Scaling group ARN and try again.

You might run a aws ecs describe-capacity-providers command and see output similar to this:

$ aws ecs describe-capacity-providers
{
  "capacityProviderArn": "arn:aws:ecs:us-west-2:123456789012:capacity-provider/my-cluster-c4f5641",
  "name": "my-cluster-c4f5641",
  "status": "ACTIVE",
  "autoScalingGroupProvider": {
    "autoScalingGroupArn": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:abcd1234-5678-90ab-cdef-1234567890ab:autoScalingGroupName/my-cluster-asg-e389cf6",
    "managedScaling": {
      "status": "DISABLED",
      "targetCapacity": 100,
      "minimumScalingStepSize": 1,
      "maximumScalingStepSize": 10000,
      "instanceWarmupPeriod": 300
    }
  }
}

In this case, the my-cluster-c4f5641 capacity provider is still visible in the CLI, but the associated ECS cluster no longer exists.

How to Clean Up the Orphaned Capacity Provider

Since the ECS cluster has been deleted, but the capacity provider remains, you need to manually delete the orphaned capacity provider.

To do this, follow these steps:

Verify the Capacity Provider Exists: Before deleting, make sure the capacity provider you’re trying to remove is indeed orphaned and no longer linked to an ECS cluster. You can use the following command to check:

aws ecs describe-capacity-providers --capacity-providers my-cluster-c4f5641

Delete the Capacity Provider: Once you confirm the capacity provider is no longer needed, you can delete it with the following command:

aws ecs delete-capacity-provider --capacity-provider my-cluster-c4f5641

Replace my-cluster-c4f5641 with the actual name of the orphaned capacity provider.

Confirm Deletion: After running the deletion command, check if the capacity provider is removed by running:

aws ecs describe-capacity-providers --capacity-providers my-cluster-c4f5641

If the capacity provider has been successfully deleted, the command should return an error indicating that the capacity provider no longer exists.

Ismail Yenigul

Devops Engineer

👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Join FAUN Developer Community & Get Similar Stories in your Inbox Each Week


메타데이터
post_id
27b9bb625ab8
slug
cleaning-up-orphaned-ecs-capacity-providers-in-aws-27b9bb625ab8
url
https://faun.pub/cleaning-up-orphaned-ecs-capacity-providers-in-aws-27b9bb625ab8
canonical_url
https://faun.pub/cleaning-up-orphaned-ecs-capacity-providers-in-aws-27b9bb625ab8
author_url
https://medium.com/@ismailyenigul
status
ok
fetched_at
2026-08-03 21:12:52