Deregistering an external instance - Amazon Elastic Container Service

Deregistering an external instance

We recommend that, after you finish using an external instance, you deregister the instance from both Amazon ECS and AWS Systems Manager. Following deregistration, the external instance is no longer able to accept new tasks.

If you have tasks that are running on the container instance when you deregister it, the tasks remain running until they stop through some other means. However, these tasks are no longer monitored or accounted for by Amazon ECS. If these tasks on your external instance are part of an Amazon ECS service, then the service scheduler starts another copy of that task, on a different instance, if possible.

To register an external instance to a new cluster, after the external instance has been deregistered from both Amazon ECS and Systems Manager, you can clean up the remaining AWS resources on the instance and register it with a new cluster.

New AWS Management Console
  1. Open the new console at https://console.aws.amazon.com/ecs/v2.

  2. From the navigation bar, choose the Region where your external instance is registered.

  3. In the navigation pane, choose Clusters and select the cluster that hosts the external instance.

  4. On the Cluster : name page, choose the Infrastructure tab.

  5. Under Container instances, select the external instance ID to deregister. You're redirected to the container instance detail page.

  6. On the Container Instance : id page, choose Deregister.

  7. Review the deregistration message. Select Deregister from AWS Systems Manager to also deregister the external instance as an Systems Manager managed instance. Choose Deregister.

    Note

    You can deregister the external instance as an Systems Manager managed instance in the Systems Manager console. For instructions, see Deregistering managed instances in the AWS Systems Manager User Guide.

Classic AWS Management Console
  1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.

  2. From the navigation bar, choose the Region where your external instance is registered.

  3. In the navigation pane, choose Clusters and select the cluster that hosts the external instance.

  4. On the Cluster : name page, choose the ECS Instances tab.

    
                                    ECS Instances tab
  5. Select the external instance ID to deregister. You're redirected to the container instance detail page.

  6. On the Container Instance : id page, choose Deregister.

  7. Review the deregistration message. Select Deregister from AWS Systems Manager to also deregister the external instance as an Systems Manager managed instance. Choose Deregister.

    Note

    You can deregister the external instance as an Systems Manager managed instance in the Systems Manager console. For instructions, see Deregistering managed instances in the AWS Systems Manager User Guide.

  8. If you want to clean up the remaining AWS resources from the external instance, follow these steps. The cleanup steps must be completed before you can register the external instance with a new cluster.

To clean up AWS resources on your on-premises server or VM

  1. Make sure that the external instance is deregistered from both Amazon ECS and Systems Manager.

  2. Stop the Amazon ECS container agent and the SSM Agent services on the instance.

    sudo systemctl stop ecs amazon-ssm-agent
  3. Remove the Amazon ECS and Systems Manager packages.

    For CentOS 7, CentOS 8, and RHEL 7

    sudo yum remove -y amazon-ecs-init amazon-ssm-agent

    For SUSE Enterprise Server 15

    sudo zypper remove -y amazon-ecs-init amazon-ssm-agent

    For Debian and Ubuntu

    sudo apt remove -y amazon-ecs-init amazon-ssm-agent
  4. Remove the Amazon ECS and Systems Manager files.

    sudo rm -rf /var/lib/ecs /etc/ecs /var/lib/amazon/ssm /var/log/ecs /var/log/amazon/ssm