When you have created many instances in AWS and have not used a few for a long time, it is time to clean up and delete the instance from AWS. It’s quite easy, and you need to perform a few quick steps to delete an instance in AWS. An important point to remember here is when you are terminating an instance, you won’t be able to reconnect it once terminated. Once you terminate an instance, it just takes a very short time to delete it automatically.
This AWS tutorial will discuss how to delete an instance in AWS and a few related FAQs.
Table of Contents
- How To Delete An Instance In AWS
- How to delete terminated EC2 instance using the AWS Management Console
- How to delete an EC2 instance using AWS CLI
- Wrapping Up
How To Delete An Instance In AWS
Follow the below steps to delete the Terminated Instance In AWS quickly.
- Locate the instance you wish to delete or terminate on the Instances page in the Amazon EC2 console.
- Right-click on the instance, from the menu, choose Instance State –> Select Terminate option.
- Finally, on the next confirmation pop-up, choose Yes to confirm the termination of the AWS instance.
Once you have terminated the AWS instance, it will take a very short period to completely delete it from the AWS console.
How to delete terminated EC2 instance using the AWS Management Console
You can easily terminate an AWS instance using the AWS management console following the below quick steps.
- The first step is to back up your data before terminating the AWS instance. Otherwise, you are going to lose your data.
- Navigate to the Amazon EC2 console ( https://console.aws.amazon.com/ec2/).
- Choose the Instances option in the navigation pane.
- Now, choose the Instance state, Terminate instance.
- Finally, you will get a confirmation pop-up now. Select the Terminate option for the confirmation.
You can also able to terminate an instance using the AWS CLI.
How to delete an EC2 instance using AWS CLI
You can follow the below quick information to terminate an instance using the AWS CLI.
You can specify the specific instances that you want to terminate.
The syntax of the AWS CLI cmdlet to terminate the instance
[--dry-run | --no-dry-run]
You can provide up to 1000 instance IDs with the AWS CLI cmdlets. But the suggestion here is to run with small batches.
Let’s consider the below example that terminates a specific instance with the specified ID.
You can execute the below AWS CLI cmdlet with the correct instance ID.
aws ec2 terminate-instances --instance-ids i-573790123yhjiuikl
You will get the output below once you execute the AWS CLI cmdlet above.
How long do terminated instances stay in AWS?
Once you terminate the instance in AWS, it stays for 1 hour approximately, and then it gets deleted permanently.
How do I reset a terminated instance?
It’s not possible to reset a terminated instance in AWS. Once you have terminated the instance, you can’t use that instance anymore and must create a new one.
Can we recover the terminated EC2 instance?
it’s impossible to recover a terminated EC2 instance. Also, you won’t be able to recover the data you might have stored locally.
What is the difference between terminating and stopping an AWS EC2 instance?
When using an AWS EC2 instance, you can stop and terminate the AWS EC2 instance.
Either you stop the AWS EC2 instance or you terminate the instance. In both cases, the instance will shut down, and the VM will be removed permanently, and you will not need to pay for the usage.
Let’s discuss the key differences between stopping and terminating the AWS EC2 instance.
|Terminating AWS EC2 Instance
|The data on your EBS volume will not be available after terminating.
|The attached bootable EBS volume will get deleted.
|The attached bootable EBS volume will not get deleted.
|The data on your EBS volume will not available after terminating.
|The data on your EBS volume will remain as it is after stopping.
Note: An important point to note here is if you plan to start the AWS EC2 instance again, you should stop the AWS EC2 instance instead of terminating it.
Who deleted the AWS EC2 instance?
Suppose you are surprised to see the deletion of any specific AWS EC2 instance and wish to know who has deleted that instance. By accessing the Amazon CloudTrail, you will know who is responsible for deleting the AWS EC2 instance.
How do I know who stopped the AWS EC2 instance?
With the help of Amazon CloudTrail, We can know who has stopped the AWS EC2 instance. Follow the below steps.
- Open the Amazon CloudTrail console and choose Event History from the navigation pane.
- Select the Event name from the Lookup attributes dropdown menu.
- Now is the time to enter the event name. You need to enter the event name based on the event. For example, enter the event name as “StopInstances” if your instance was stopped. If your instance was terminated, enter the event name as “TerminateInstances.”
- On the event details page, choose the event name as StopInstances or TerminateInstances. Now, you can see the name of the AWS Identity and IAM user who initiated the event.
This article discussed how to delete instances in AWS and a few related FAQs.
I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.