Search code examples
amazon-web-servicesterraformamazon-ecsterraform-provider-aws

Cannot delete capcity provider


I'm trying to build some infrastructure using Terraform. This includes an ECS cluster and a capacity provider for said cluster.

The capacity provider was successfully created, but then I changed its name because I accidentally left it as "example". By changing the name, Terraform attempts to destroy the existing "example" capacity provider and create a new one.

Terraform fails with:

The capacity provider cannot be deleted because it is associated with cluster: my-cluster. Remove the capacity provider from the cluster and try again.

So I go to update the cluster in the console, and I remove the capacity provider from the cluster and save the cluster. Then, I try again, but it keeps failing with the same error message.

How can I possibly delete this capacity provider? Surely, this must be a bug in AWS?


Solution

  • While I had disassociated the capacity provider from the cluster, I hadn't deleted it, and it seems it was still considered associated for whatever reason. By actually deleting the capacity provider under the "Capacity Providers" tab of the cluster, I was able to proceed.