How To Delete AWS EC2 Instance – Complete Guide

How To Delete AWS EC2 Instance – Complete Guide

Amazon Web Services (AWS) is a well-known cloud platform that offers a plethora of services to manage and scale applications. One of the most popular services is the Elastic Compute Cloud (EC2), which allows users to create virtual machines (instances) and run applications on them. In this blog post, we will explore the process of deleting an EC2 instance on AWS. This guide is tailored for codedamn readers who are familiar with AWS and EC2 concepts and are looking for a detailed explanation of how to terminate an EC2 instance.

EC2 Basics

Before we dive into the process of deleting an EC2 instance, let's quickly discuss some basic concepts related to EC2 instances.


An EC2 instance is a virtual server hosted on Amazon's cloud infrastructure. Instances come in various sizes and configurations, which are optimized for different workloads. You can choose from a range of instance types based on your application requirements, such as memory, storage, and compute capacity.

Instance States

An EC2 instance can be in one of the following states:

  • Running: The instance is currently operational, and you can access it via SSH or other remote access methods.
  • Stopped: The instance has been shut down, but its resources (such as EBS volumes and elastic IP addresses) are still allocated to it.
  • Terminated: The instance has been deleted, and its resources have been released.

In this guide, we will focus on the process of terminating an EC2 instance.

How To Delete an EC2 Instance

To delete an EC2 instance, you will need to terminate it. This process involves the following steps:

Step 1: Log in to AWS Management Console

First, log in to your AWS Management Console. If you don't already have an account, you can sign up for a free trial account here.

Step 2: Navigate to the EC2 Dashboard

Once you've logged in to the AWS Management Console, click on "Services" in the top navigation bar and select "EC2" from the dropdown menu. This will take you to the EC2 Dashboard.

Step 3: Select the Instance to be Deleted

On the EC2 Dashboard, click on "Instances" in the left-hand menu to view a list of your running instances. Select the instance you want to delete by clicking on the checkbox next to its name.

Step 4: Terminate the Instance

With the instance selected, click on the "Actions" dropdown menu and select "Instance State" > "Terminate." A confirmation dialog will appear, asking you to confirm that you want to terminate the instance. Click "Yes, Terminate" to proceed.

Keep in mind that terminating an instance is a permanent action and cannot be undone. Make sure to back up any data or configurations you need before proceeding.

The instance's state will change to "shutting-down," followed by "terminated" once the termination process is complete. It may take a few minutes for the instance to be completely terminated.

Deleting an EC2 Instance Using AWS CLI

In addition to using the AWS Management Console, you can also delete an EC2 instance using the AWS Command Line Interface (CLI). To do this, follow these steps:

Step 1: Install and Configure AWS CLI

If you haven't already installed the AWS CLI, you can download it from the official AWS CLI website. Follow the installation instructions for your operating system.

Once the CLI is installed, you'll need to configure it with your AWS credentials. Run the following command and follow the prompts:

aws configure

Step 2: Find the Instance ID

To delete an EC2 instance using the CLI, you'll need its Instance ID. You can retrieve this by running the following command:

aws ec2 describe-instances

This command will return a JSON output containing information about your instances. Locate the instance you want to delete, and take note of its Instance ID.

Step 3: Terminate the Instance

With the Instance ID in hand, you can now terminate the instance by running the following command:

aws ec2 terminate-instances --instance-ids i-1234567890abcdef0

Replace i-1234567890abcdef0 with the Instance ID of the instance you want to delete. The command will return a JSON output confirming that the instance is in the process of being terminated.


Q: What happens when I terminate an EC2 instance?

A: When you terminate an EC2 instance, AWS shuts down the instance and releases its associated resources, such as EBS volumes and elastic IP addresses. Any data stored on the instance will be lost unless you have created a backup.

Q: Can I recover a terminated EC2 instance?

A: No, you cannot recover a terminated EC2 instance. Termination is a permanent action, and any data or configurations associated with the instance will be lost. It's essential to back up any necessary data before terminating an instance.

Q: How do I know if my EC2 instance has been terminated successfully?

A: You can check the status of your instance in the AWS Management Console or by running the aws ec2 describe-instances command in the AWS CLI. If the instance's state is listed as "terminated," the termination process has been completed successfully.

Q: Can I stop an EC2 instance instead of terminating it?

A: Yes, you can stop an instance instead of terminating it. Stopping an instance will shut it down, but its resources (such as EBS volumes and elastic IP addresses) will remain allocated to it. This allows you to restart the instance later if needed. To stop an instance, follow the same steps as above but choose "Stop" instead of "Terminate" in the AWS Management Console or use the aws ec2 stop-instances command in the AWS CLI.

In conclusion, this guide has provided a complete and thorough explanation of how to delete an AWS EC2 instance through the AWS Management Console and the AWS CLI. Remember to back up any essential data before terminating an instance, as this action is permanent and cannot be undone. For more information on EC2 instances and other AWS services, refer to the official AWS documentation.

Sharing is caring

Did you like what Vishnupriya wrote? Thank them for their work by sharing it on social media.


No comments so far