How to Delete an EC2 Instance | In-Depth Guide

Deleting an EC2 instance is pretty easy, whether through AWS Management Console or the Command Line Interface. But once you terminate an EC2 instance, you cannot undo it. So, you may want to stop or hibernate as an alternative to deleting. That said, you can always launch more instances with the same AMI.

How to Delete an EC2 Instance

Can You Terminate an EC2 Instance?

If you no longer need an EC2 instance, you can choose to delete (terminate) it. And you’ll stop incurring charges immediately after its state turns to terminated.

You have to keep in mind that once you terminate an instance, there’s no way of connecting it after that. So, we recommend you back up any data or configs you may need later.

When you terminate an EC2 instance, all Amazon EBS root device volumes get deleted. However, additional EBS volumes attached to an existing instance will persist after termination. It is a default behavior though you can modify the DeleteOnTermination attribute of an EBS volume.

What Happens When You Delete an EC2 Instance?

When you delete an EC2 instance using the terminate-instances command, this is what happens on the OS level:

  1. There will be an API request for a button press event.
  2. System services will stop due to the button press, resulting in a graceful shutdown instead of an instant one. The shutdown gets triggered by the ACPI button press.
  3. The system initiates the ACPI shutdown.
  4. After the graceful shutdown period, the instance terminates with zero configurable OS shutdown time.

Once the shutdown process is complete, all associated resources like Elastic IPs, tags, and EBS volumes, including any data you stored, will get disassociated.

How Do I Delete Unused EC2 Instances?

Deleting an EC2 instance refers to the term ‘termination’, which you can do using the console or command lines.

Deleting EC2 Instances Via AWS Management Console

Deleting your EC2 instances through the AWS console is a simple 4 step process as shown below.

1. Sign into your AWS Management Console

Before you can delete your EC2 instance, you have to log into your AWS Management Console account.

2. Head over to the EC2 Dashboard

From your AWS Management Console homepage, click ‘Services’ to view your EC2 dashboard. You’ll find it on the navigation bar at the top.

3. Select the EC2 instance you want to delete 

From you EC2 Dashboard, go to the navigation pane and click ‘Instances’. All your running instances, each with a checkbox, will appear in a list-view. 

Click on the checkboxes to select the EC2 instances to be terminated.

4. Terminate the EC2 instance

After selecting the instances, click on Instance State followed by Terminate Instance. 

There should be a popup dialog box in front of you. Confirm your choice by clicking on Terminate.

Once the termination process is over, the state of the EC2 instance will turn to ‘shutting down’ and then ‘terminated’. 

It may take a couple of minutes to change.

Deleting EC2 Instances Using Command Lines

You can also delete EC2 instances using AWS Command Line Interface. Here’s how.

1. Install AWS Command Line Interface

Download the AWS CLI from the official website and install it. After the installation is complete, run the command ‘aws configure’ and configure it using your credentials.

2. Get the instance ID of the EC2 instance

Use the following command to retrieve the Instance ID of the EC2 instance you want to delete.

aws ec2 describe-instances

A JSON output with information about all your EC2 instances will appear. Locate your target instance and copy its Instance ID.

3. Delete the EC2 instance

To delete the EC2 instance, run the command below.

aws ec2 terminate-instances –instance-ids “paste instance id here”

Another JSON output will let you know that the EC2 instance is being terminated.

Frequently Asked Questions

Do Terminated EC2 Instances Go Away?

Terminated EC2 instances will stay visible in the console for a few minutes before going away. So, there’s nothing to worry about if an EC2 instance remains visible after termination. Check back after an hour, and the instance should no longer be visible.

Will I Get Charged if I Stop My EC2 Instance?

If you stop an EC2 instance, AWS will no longer charge you any instance usage fees for that instance. But resources like EBS volumes attached to stopped instances may still contribute to your charges. That’s not the case with termination, as the resources get released.


If you cannot delete an EC2 instance using either of the methods mentioned here, you probably have termination protection enabled for it. You can disable the termination protection by selecting the instance, choosing Actions > Instance Settings> Change Termination Protection, and clicking ‘Yes, Disable’.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *