Terminate a cluster - Amazon EMR

Terminate a cluster

This section describes the methods of terminating a cluster. For information about enabling termination protection and auto-terminating clusters, see Control cluster termination. You can terminate clusters in the STARTING, RUNNING, or WAITING states. A cluster in the WAITING state must be terminated or it runs indefinitely, generating charges to your account. You can terminate a cluster that fails to leave the STARTING state or is unable to complete a step.

If you want to terminate a cluster that has termination protection set on it, you must disable termination protection before you can terminate the cluster. Clusters can be terminated using the console, the AWS CLI, or programmatically using the TerminateJobFlows API.

Depending on the configuration of the cluster, it could take from 5 to 20 minutes for the cluster to completely terminate and release allocated resources, such as EC2 instances.

Note

You can't restart a terminated cluster, but you can clone a terminated cluster to reuse its configuration for a new cluster. For more information, see Cloning a cluster using the console.

Important

Amazon EMR uses the Amazon EMR service role and the AWSServiceRoleForEMRCleanup role to clean up cluster resources in your account that you no longer use, such as Amazon EC2 instances. You must include actions for the role policies to delete or terminate the resources. Otherwise, Amazon EMR can’t perform these cleanup actions, and you might incur costs for unused resources that remain on the cluster.

Terminate a cluster with the console

You can terminate one or more clusters using the Amazon EMR console. The steps to terminate a cluster in the console vary depending on whether termination protection is on or off. To terminate a protected cluster, you must first disable termination protection.

New console
To terminate a cluster with the new console
  1. Sign in to the AWS Management Console, and open the Amazon EMR console at https://console.aws.amazon.com/emr.

  2. Choose Clusters, and then choose the cluster you want to terminate.

  3. Under the Actions dropdown menu, choose Terminate cluster to open the Terminate cluster prompt.

  4. At the prompt, choose Terminate. Depending on the cluster configuration, termination may take 5 to 10 minutes. For more information on how to Amazon EMR clusters, see Terminate a cluster.

Old console
To terminate a cluster with termination protection off with the old console
  1. Navigate to the new Amazon EMR console and select Switch to the old console from the side navigation. For more information on what to expect when you switch to the old console, see Using the old console.

  2. Select the cluster to terminate. You can select multiple clusters and terminate them at the same time.

  3. Choose Terminate.

  4. When prompted, choose Terminate.

    Amazon EMR terminates the instances in the cluster and stops saving log data.

To terminate a cluster with termination protection on with the old console
  1. Navigate to the new Amazon EMR console and select Switch to the old console from the side navigation. For more information on what to expect when you switch to the old console, see Using the old console.

  2. On the Cluster List page, select the cluster to terminate. You can select multiple clusters and terminate them at the same time.

  3. Choose Terminate.

  4. When prompted, choose Change to turn termination protection off. If you selected multiple clusters, choose Turn off all to disable termination protection for all the clusters at once.

  5. In the Terminate clusters dialog, for Termination Protection, choose Off and then click the check mark to confirm.

  6. Click Terminate.

    Amazon EMR terminates the instances in the cluster and stops saving log data.

Terminate a cluster with the AWS CLI

To terminate an unprotected cluster using the AWS CLI

To terminate an unprotected cluster using the AWS CLI, use the terminate-clusters subcommand with the --cluster-ids parameter.

  • Type the following command to terminate a single cluster and replace j-3KVXXXXXXX7UG with your cluster ID.

    aws emr terminate-clusters --cluster-ids j-3KVXXXXXXX7UG

    To terminate multiple clusters, type the following command and replace j-3KVXXXXXXX7UG and j-WJ2XXXXXX8EU with your cluster IDs.

    aws emr terminate-clusters --cluster-ids j-3KVXXXXXXX7UG j-WJ2XXXXXX8EU

    For more information on using Amazon EMR commands in the AWS CLI, see https://docs.aws.amazon.com/cli/latest/reference/emr.

To terminate a protected cluster using the AWS CLI

To terminate a protected cluster using the AWS CLI, first disable termination protection using the modify-cluster-attributes subcommand with the --no-termination-protected parameter. Then use the terminate-clusters subcommand with the --cluster-ids parameter to terminate it.

  1. Type the following command to disable termination protection and replace j-3KVTXXXXXX7UG with your cluster ID.

    aws emr modify-cluster-attributes --cluster-id j-3KVTXXXXXX7UG --no-termination-protected
  2. To terminate the cluster, type the following command and replace j-3KVXXXXXXX7UG with your cluster ID.

    aws emr terminate-clusters --cluster-ids j-3KVXXXXXXX7UG

    To terminate multiple clusters, type the following command and replace j-3KVXXXXXXX7UG and j-WJ2XXXXXX8EU with your cluster IDs.

    aws emr terminate-clusters --cluster-ids j-3KVXXXXXXX7UG j-WJ2XXXXXX8EU

    For more information on using Amazon EMR commands in the AWS CLI, see https://docs.aws.amazon.com/cli/latest/reference/emr.

Terminate a cluster with the API

The TerminateJobFlows operation ends step processing, uploads any log data from Amazon EC2 to Amazon S3 (if configured), and terminates the Hadoop cluster. A cluster also terminates automatically if you set KeepJobAliveWhenNoSteps to False in a RunJobFlows request.

You can use this action to terminate either a single cluster or a list of clusters by their cluster IDs.

For more information about the input parameters unique to TerminateJobFlows, see TerminateJobFlows. For more information about the generic parameters in the request, see Common request parameters.