How to Delete Terminated EC2 Instances in AWS
To delete terminated EC2 Instances, locate the instance you want to delete in the EC2 Console under the Instances page. Click on the instance and select the Terminate option. Once you’ve selected “terminate,” you will receive a pop-up confirmation. Click “Yes” to confirm.
The instance will remain on the AWS console for about an hour before the system deletes it completely. After you terminate an instance, you will also delete all attached Amazon EBS volumes. However, any volumes attached after launching the instance will persist. It is essential to back up the data before terminating the instance.
Terminating vs. Stopping an Instance
You can either terminate or stop an instance from running. Terminating or stopping an instance ensures it does not accrue additional charges. The instance will shut down in both, and the virtual machines will disappear.
Stopping an instance is a general action a cloud administrator applies during maintenance. Sometimes it is required for specific reasons like changing instance type, applying any patches, etc. After stopping, we can start the instance at any time if needed.
When stopping an instance, EBS volume will remain. The attached bootable EBS volume will also remain. The volume will continue persisting in its availability zone and will incur standard charges. It is a good idea to stop any instances that you will not be using for a short period. Unless you plan to start an instance within a short time, you should terminate it to avoid any unnecessary charges.
Can I Restart a Terminated Instance?
Protecting EC2 Instances from Termination
Since you cannot restart a terminated instance, protecting your instances from accidental termination is essential. This saves you from losing resources and crucial data.
Here are some handy ways to prevent EC2 Instance termination:
AWS Termination Protection
You can enable AWS termination protection to prevent accidental deletion. The DisableApiTermination attribute is responsible for preventing accidental deletion. However, you cannot protect the termination of Spot Instances. Spot Instances will automatically terminate after you have exceeded the agreed-upon price.
You can enable termination protection under the Instance Settings on the Actions page for running and stopping instances.
Select your EC2 Instance > Action > Instance Settings > Change termination protection > Check or uncheck the box as needed.
You can disable this protection at any time through the Instance Settings.
Identity and Access Management (IAM)
Access management is crucial when it comes to using AWS resources securely. AWS Identity and Access Management (IAM) is a service that helps manage user identities and access to AWS resources. It enables you to centrally manage permissions for controlling the resources users can access. IAM is used for authentication and authorization purposes, allowing you to create or manage resources at AWS and manage IAM users, groups, and roles. For enhanced security, IAM also offers multi-factor authentication (MFA). The best part is that it is a free service, with no additional charges.
Manage EC2 Instances with nOps
nSwitch is a powerful solution that helps you identify the idle resources and recommends the best time for shutting down, which saves you money in the process. nOps sends signals to resources and toggles them on or off during scheduled times using EventBridge. You can explore more about nSwitch here.
Let engineers focus on engineering; let nOps focus on FinOps.