How to Delete an EC2 Instance: A Step-by-Step Guide

How to Delete an EC2 Instance: A Step-by-Step Guide

We’re going to dive into a super common task: deleting an EC2 instance on Amazon Web Services (AWS). No fancy talk, just a straightforward guide.

But First, Prerequisites

Before we hit the delete button, here’s what you need:

  1. Permissions: Make sure you have the green light to delete EC2 instances in your AWS account. Nobody likes the “access denied” message!
  2. Double-Check: Don’t rush. Identify the right instance you want to delete. We don’t want any oops moments, right?

Using the AWS Management Console

The following steps show how to delete an EC2 Instance using the AWS Management Console:

Step 1: Access the AWS Management Console

  1. Open your web browser and navigate to the AWS Management Console at
  2. Log in to your AWS account using valid credentials.

Step 2: Navigate to the EC2 Dashboard

  1. Once logged in, click on “Services” in the top navigation bar.
  2. In the “Find services” search box, type “EC2” and select “EC2” from the options that appear.
  3. You will be redirected to the EC2 Dashboard.

Step 3: Locate the EC2 Instance to be Deleted

  1. In the EC2 Dashboard, select “Instances” from the left-hand navigation pane.
  2. Identify the EC2 instance you wish to delete from the list. Take note of its Instance ID and other relevant details.

Step 4: Stop the EC2 Instance (optional but recommended)

  1. Right-click on the EC2 instance to be deleted and select “Instance State” followed by “Stop.”
  2. A confirmation dialog will appear. Click “Yes, Stop” to stop the instance gracefully. Note: Stopping the instance before deletion ensures that all running processes are properly terminated and any in-flight operations are completed.

Step 5: Delete the EC2 Instance

  1. Right-click on the EC2 instance to be deleted and select “Instance State” followed by “Terminate.”
  2. A warning dialog will appear, explaining that terminating the instance cannot be undone. Review the information carefully.
  3. Click “Yes, Terminate” to initiate the deletion process.

Step 6: Confirm the Deletion

  1. Once you confirm the termination, the EC2 instance will enter the “shutting-down” state.
  2. Refresh the instance list periodically until the instance no longer appears, indicating that the deletion is complete.

Command-Line Interface (CLI) Equivalent

Alternatively, you can use the AWS CLI to delete an EC2 instance. Here’s an example command:

aws ec2 terminate-instances --instance-ids <instance-id>

Replace <instance-id> with the actual ID of the instance you want to delete.

Troubleshooting Issues When Deleting an EC2 Instance

While deleting an EC2 instance is typically a straightforward process, there are instances where you may encounter issues or face challenges. In this section, we will discuss common troubleshooting scenarios and provide solutions to help you overcome potential hurdles during the deletion process.

Issue #1: Instance Deletion Failure

Problem: Occasionally, an EC2 instance may fail to terminate properly, resulting in an error message or the instance remaining in a running state.


  • Verify that you have the necessary permissions to terminate instances.
  • Ensure the instance is not a part of an Auto Scaling group or Elastic Beanstalk environment. Instances associated with these services cannot be terminated individually.
  • Check if there are any pending operations or scheduled actions associated with the instance. Cancel or complete these actions before attempting deletion.
  • If the instance is unresponsive, try stopping it first before terminating it.
  • If the problem persists, contact AWS Support for further assistance.

Issue #2: Attached Resources Preventing Deletion

Problem: An EC2 instance may have attached resources, such as EBS volumes, network interfaces, or security groups, which can prevent successful termination.


  • Detach any attached resources manually before attempting to delete the instance. For example, detach EBS volumes or release elastic IP addresses associated with the instance.
  • Ensure that no other resources rely on the instance or its associated resources. Adjust dependencies accordingly.

Issue #3: Volume Deletion Failure

Problem: When deleting an EC2 instance, the associated EBS volumes may fail to be deleted, resulting in lingering volumes.


  • Verify that the EBS volume is not actively in use by other EC2 instances.
  • Manually delete the EBS volume through the EC2 Dashboard or CLI if it remains unattached after instance termination.
  • If the volume is encrypted, ensure you have the necessary encryption keys to delete it.

Issue #4: Incorrect Instance Identification

Problem: Mistakenly identifying and attempting to delete the wrong EC2 instance can have serious consequences.


  • Double-check the Instance ID, tags, and other identifying details of the instance before initiating termination.
  • Take note of the instance’s name, tags, or other unique identifiers to ensure accuracy.

Issue #5: Insufficient Permissions

Problem: You may encounter permission-related issues while trying to delete an EC2 instance, such as receiving an “Access Denied” error.


  • Confirm that your IAM user or role has the necessary permissions to terminate EC2 instances. Check for any explicit “deny” permissions that may override your desired actions.
  • Consult with your AWS account administrator to grant or adjust the required permissions.

Issue #6: Instance Termination Protection Enabled

Problem: If instance termination protection is enabled, it prevents the termination of EC2 instances, even if a deletion request is initiated.


  • Check if instance termination protection is enabled for the EC2 instance you want to delete.
  • Disable termination protection by following these steps:
    • Navigate to the EC2 Dashboard in the AWS Management Console.
    • Select the EC2 instance that has termination protection enabled.
    • Right-click on the instance and choose “Instance Settings,” followed by “Change Termination Protection.”
    • Uncheck the option for termination protection and save the changes.
  • After disabling termination protection, retry the instance deletion process.