Skip to content

can't delete ecs cluster

0

VPC was accidentally deleted before ECS Managed Instances and Capacity Provider cleanup completed. cluster cannot be deleted because the capacity provider remains attached. capacity providers scaliing type Managed Instances There was an error deleting capacity provider a. Service Unavailable. Please try again later. 2026-06-17 17:46:12,609 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.13.17 Python/3.11.5 Darwin/22.6.0 exe/x86_64 2026-06-17 17:46:12,609 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['ecs', 'delete-capacity-provider', '--capacity-provider', 'a', '--debug'] 2026-06-17 17:46:12,634 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_s3 at 0x1062bc360> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_ddb at 0x1060e9d00> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.configure.configure.ConfigureCommand'>> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x10604fd80> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function change_name at 0x1060693a0> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function alias_opsworks_cm at 0x1062bede0> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_history_commands at 0x10614c720> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method BasicCommand.add_command of <class 'awscli.customizations.devcommands.CLIDevCommand'>> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <function add_waiters at 0x1062beca0> 2026-06-17 17:46:12,635 - MainThread - botocore.hooks - DEBUG - Event building-command-table.main: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x106381350>> 2026-06-17 17:46:12,635 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/data/cli.json 2026-06-17 17:46:12,637 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_types at 0x1061f6020> 2026-06-17 17:46:12,637 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function no_sign_request at 0x1061f6340> 2026-06-17 17:46:12,637 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_verify_ssl at 0x1061f62a0> 2026-06-17 17:46:12,637 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_read_timeout at 0x1061f6480> 2026-06-17 17:46:12,637 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <function resolve_cli_connect_timeout at 0x1061f63e0> 2026-06-17 17:46:12,638 - MainThread - botocore.hooks - DEBUG - Event top-level-args-parsed: calling handler <built-in method update of dict object at 0x10637a500> 2026-06-17 17:46:12,638 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/2.13.17 Python/3.11.5 Darwin/22.6.0 exe/x86_64 prompt/off 2026-06-17 17:46:12,638 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['ecs', 'delete-capacity-provider', '--capacity-provider', 'a', '--debug'] 2026-06-17 17:46:12,638 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_timestamp_parser at 0x1062bccc0> 2026-06-17 17:46:12,638 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x105bee8e0> 2026-06-17 17:46:12,638 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_binary_formatter at 0x106340220> 2026-06-17 17:46:12,639 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function no_pager_handler at 0x105ae4c20> 2026-06-17 17:46:12,639 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x105c06200> 2026-06-17 17:46:12,641 - MainThread - botocore.utils - DEBUG - IMDS ENDPOINT: http://169.254.169.254/ 2026-06-17 17:46:12,651 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x106118ea0> 2026-06-17 17:46:12,651 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_json_file_cache at 0x1060c1f80> 2026-06-17 17:46:12,679 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/ecs/2014-11-13/service-2.json 2026-06-17 17:46:12,691 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ecs: calling handler <function inject_commands at 0x1061ce840> 2026-06-17 17:46:12,691 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ecs: calling handler <function add_waiters at 0x1062beca0> 2026-06-17 17:46:12,719 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/ecs/2014-11-13/waiters-2.json 2026-06-17 17:46:12,719 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ecs: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x106381350>> 2026-06-17 17:46:12,720 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('capacity-provider', <awscli.arguments.CLIArgument object at 0x1064e4f10>)]) 2026-06-17 17:46:12,720 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function add_streaming_output_arg at 0x1062bd1c0> 2026-06-17 17:46:12,721 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function rename_arg.<locals>._rename_arg at 0x106343f60> 2026-06-17 17:46:12,721 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function add_cli_input_json at 0x105c06b60> 2026-06-17 17:46:12,721 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function add_cli_input_yaml at 0x105c06c00> 2026-06-17 17:46:12,721 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function unify_paging_params at 0x1060ea340> 2026-06-17 17:46:12,755 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/ecs/2014-11-13/paginators-1.json 2026-06-17 17:46:12,755 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.ecs.delete-capacity-provider: calling handler <function add_generate_skeleton at 0x1061f4860> 2026-06-17 17:46:12,756 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ecs.delete-capacity-provider: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x106557d90>> 2026-06-17 17:46:12,756 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ecs.delete-capacity-provider: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x106557e90>> 2026-06-17 17:46:12,756 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.ecs.delete-capacity-provider: calling handler <bound method GenerateCliSkeletonArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x106561e10>> 2026-06-17 17:46:12,756 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ecs_delete-capacity-provider: calling handler <function add_waiters at 0x1062beca0> 2026-06-17 17:46:12,756 - MainThread - botocore.hooks - DEBUG - Event building-command-table.ecs_delete-capacity-provider: calling handler <bound method AliasSubCommandInjector.on_building_command_table of <awscli.alias.AliasSubCommandInjector object at 0x106381350>> 2026-06-17 17:46:12,757 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ecs.delete-capacity-provider.capacity-provider: calling handler <awscli.paramfile.URIArgumentHandler object at 0x1063820d0> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event process-cli-arg.ecs.delete-capacity-provider: calling handler <awscli.argprocess.ParamShorthandParser object at 0x105b07850> 2026-06-17 17:46:12,758 - MainThread - awscli.arguments - DEBUG - Unpacked value of 'a' for parameter "capacity_provider": 'a' 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ecs.delete-capacity-provider.cli-input-json: calling handler <awscli.paramfile.URIArgumentHandler object at 0x1063820d0> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ecs.delete-capacity-provider.cli-input-yaml: calling handler <awscli.paramfile.URIArgumentHandler object at 0x1063820d0> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.ecs.delete-capacity-provider.generate-cli-skeleton: calling handler <awscli.paramfile.URIArgumentHandler object at 0x1063820d0> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event calling-command.ecs.delete-capacity-provider: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputJSONArgument object at 0x106557d90>> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event calling-command.ecs.delete-capacity-provider: calling handler <bound method CliInputArgument.add_to_call_parameters of <awscli.customizations.cliinput.CliInputYAMLArgument object at 0x106557e90>> 2026-06-17 17:46:12,758 - MainThread - botocore.hooks - DEBUG - Event calling-command.ecs.delete-capacity-provider: calling handler <bound method GenerateCliSkeletonArgument.generate_skeleton of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x106561e10>> 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file 2026-06-17 17:46:12,759 - MainThread - botocore.credentials - INFO - Found credentials in shared credentials file: ~/.aws/credentials 2026-06-17 17:46:12,760 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/endpoints.json 2026-06-17 17:46:12,779 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x104be6660> 2026-06-17 17:46:12,808 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/ecs/2014-11-13/endpoint-rule-set-1.json 2026-06-17 17:46:12,808 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/awscli/botocore/data/partitions.json 2026-06-17 17:46:12,809 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.ecs: calling handler <function add_generate_presigned_url at 0x104b3ab60> 2026-06-17 17:46:12,810 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ecs via: environment_service 2026-06-17 17:46:12,810 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ecs via: environment_global 2026-06-17 17:46:12,810 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ecs via: config_service 2026-06-17 17:46:12,810 - MainThread - botocore.configprovider - DEBUG - Looking for endpoint for ecs via: config_global 2026-06-17 17:46:12,810 - MainThread - botocore.configprovider - DEBUG - No configured endpoint found. 2026-06-17 17:46:12,822 - MainThread - botocore.endpoint - DEBUG - Setting ecs timeout as (60, 60) 2026-06-17 17:46:12,824 - MainThread - botocore.regions - DEBUG - Calling endpoint provider with parameters: {'Region': 'ap-northeast-2', 'UseDualStack': False, 'UseFIPS': False} 2026-06-17 17:46:12,825 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://ecs.ap-northeast-2.amazonaws.com 2026-06-17 17:46:12,825 - MainThread - botocore.hooks - DEBUG - Event provide-client-params.ecs.DeleteCapacityProvider: calling handler <function base64_decode_input_blobs at 0x1063402c0> 2026-06-17 17:46:12,825 - MainThread - botocore.hooks - DEBUG - Event before-parameter-build.ecs.DeleteCapacityProvider: calling handler <function generate_idempotent_uuid at 0x104c08900> 2026-06-17 17:46:12,825 - MainThread - botocore.hooks - DEBUG - Event before-call.ecs.DeleteCapacityProvider: calling handler <function inject_api_version_header_if_needed at 0x104c0a3e0> 2026-06-17 17:46:12,825 - MainThread - botocore.endpoint - DEBUG - Making request for OperationModel(name=DeleteCapacityProvider) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'X-Amz-Target': 'AmazonEC2ContainerServiceV20141113.DeleteCapacityProvider', 'Content-Type': 'application/x-amz-json-1.1', 'User-Agent': 'aws-cli/2.13.17 Python/3.11.5 Darwin/22.6.0 exe/x86_64 prompt/off command/ecs.delete-capacity-provider'}, 'body': b'{"capacityProvider": "a"}', 'url': 'https://ecs.ap-northeast-2.amazonaws.com/', 'context': {'client_region': 'ap-northeast-2', 'client_config': <botocore.config.Config object at 0x10aa86490>, 'has_streaming_input': False, 'auth_type': None}} 2026-06-17 17:46:12,825 - MainThread - botocore.hooks - DEBUG - Event request-created.ecs.DeleteCapacityProvider: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x1064f4890>> 2026-06-17 17:46:12,825 - MainThread - botocore.hooks - DEBUG - Event choose-signer.ecs.DeleteCapacityProvider: calling handler <function set_operation_specific_signer at 0x104c087c0> 2026-06-17 17:46:12,825 - MainThread - botocore.auth - DEBUG - Calculating signature using v4 auth. 2026-06-17 17:46:12,825 - MainThread - botocore.auth - DEBUG - CanonicalRequest: POST /

content-type:application/x-amz-json-1.1 host:

asked 2 months ago60 views

1 Answer
0

I understand you're experiencing a challenging situation where your ECS cluster cannot be deleted because a capacity provider with Managed Instances scaling type remains attached, and the VPC was accidentally deleted before the cleanup process completed. The "Service Unavailable. Please try again later" error you're encountering when attempting to delete the capacity provider suggests a temporary service issue or a dependency problem caused by the missing VPC.

Here are some steps to help resolve this situation:

First, verify the cluster and capacity provider status:

  • Check if the cluster is in an INACTIVE state. The cluster must be inactive before it can be deleted.
  • Confirm that all container instances have been deregistered from the cluster.
  • Verify that all ECS services in the cluster have been deleted or stopped.

For the capacity provider deletion issue:

Since you're receiving a "Service Unavailable" error, this could indicate that the capacity provider is in an inconsistent state due to the VPC deletion. The capacity provider likely has references to resources (like Auto Scaling groups or EC2 instances) that were in the deleted VPC.

Recommended troubleshooting steps:

  1. Wait and retry: The "Service Unavailable" error may be temporary. Wait a few minutes and retry the delete-capacity-provider command.

  2. Check for active container instances: Even though the VPC is deleted, there may still be container instance registrations. Try to deregister any remaining container instances from the cluster.

  3. Disassociate the capacity provider from the cluster: Before deleting the capacity provider, ensure it's been disassociated from the cluster using the put-cluster-capacity-providers command with an empty list.

  4. Contact AWS Support: Given the complexity of this situation (deleted VPC with orphaned capacity provider), you may need assistance from AWS Support to manually clean up the resources. You can open a support case through the AWS Support Center at https://console.aws.amazon.com/support/ to request help with removing the stuck capacity provider and cluster.

The key issue here is that the capacity provider cannot be deleted while it's still associated with the cluster, and the cluster cannot be deleted while the capacity provider is attached. Breaking this dependency cycle, especially with the VPC already deleted, may require backend intervention.
Sources
How to troubleshoot "Error occurred during operation 'DeleteClusters SDK Error: The Cluster cannot be deleted while Services are active." when deleting ECS cluster from CloudFormation? | AWS re:Post
DeleteCluster - Amazon Elastic Container Service

answered 2 months ago

EXPERT

reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.