If you're using AWS without regularly checking for and removing unattached AWS resources, you may be incurring unnecessary costs. Amazon charges based on the entire pool of resources you have access to, not just based on which resources are actively in use. Performing periodic checks on your resources during and after development is essential to good AWS hygiene and can help lower overhead.
The three resources most likely to be overlooked are EBS volumes, ENIs, and NAT gateways. Here are three quick checks you can perform to ensure you're not swimming in excess resources, along with instructions on removing any extra resources you may uncover while performing these checks.
It’s important to note that you’ll need to run each check for as many regions as you are running in or have run resources in. Ok, let’s dive in.
Finding and Removing All Unattached EBS Volumes
Unattached AWS resources often take the form of EBS volumes. To find and remove any unattached EBS volumes, here are the seven steps to follow:
- Open the AWS Management Console.
- Open the EC2 dashboard.
- In the navigation panel on the left side of the screen, under Elastic Block Store, select Volumes.
- This page lists all of your EBS volumes. Look in the State column, which will show the status of each volume.
- If the status of an EBS volume is listed as Available, then the volume isn't currently attached.
- Select an unused volume, select Actions, then Delete Volume.
- The console will ask for confirmation. If you're sure that you don't need this volume, click Delete.
Note that it is not possible to delete an attached volume. If your AWS services are running as expected and it's possible to delete a volume, that volume likely should be deleted.
Finding and Removing All Unattached ENI Volumes
Here are the ten steps to manually find and release any unattached ENIs.
- Open the AWS Management Console.
- Open the AWS EC2 dashboard.
- In the navigation panel on the left side of the screen, under Network & Security, select Network Interfaces. This screen lists all of your ENIs.
- Select an ENI from the list and click on the Details tab located in the control panel at the bottom of the screen.
- Look at the Status of the ENI. If it's listed as Available, the ENI is not attached to an EC2 instance and can be removed.
- If you're using EC2-Classic, note the IP address associated with the ENI (this is also listed on the Details tab).
- If you're using EC2-VPC, note the allocation ID for the ENI.
- To release an EC2 address, open the command line.
- If you're using EC2-Classic, type:
aws ec2 release-address --public-ip <your-EC2-IP>
- If you're using ECC-VPC, type:
aws ec2 release-address --allocation-id eipalloc-64d5890a
Note that if these commands successfully release an ENI, no output is returned.
Finding and Removing All Unused NAT Gateways
Here are the eleven steps to manually find and remove any unused NAT gateways and release any Elastic IPs associated with them.
- Open the AWS VPC console.
- In the navigation panel on the left side of the screen, click on NAT Gateways.
- This page lists all of your NAT gateways. Look in the State column, which will show the status of each gateway.
- Any gateways listed as Available are not currently in use and can be deleted.
- Click on the Details tab for any available NAT gateways. Note the name of the EIP associated with the NAT gateway you wish to delete, as you may be able to release the EIP after deleting the NAT gateway.
- Click the radio button for the NAT Gateway you wish to delete, then click Actions, and Delete NAT gateway.
- A confirmation box will appear. Type delete, and then click Delete.
- If you will not need the Elastic IP associated with that NAT Gateway, you can safely release that EIP, further saving resources.
- To release the EIP associated with the now-deleted NAT Gateway, click Elastic IPs.
- Select the Elastic IP you wish to release, and then click Actions, Release Elastic IP addresses.
- A confirmation dialog box will appear. Click Release.
Alternatively, you can release the EIP through the command line. There are four different ways to release an elastic IP address using the command line, depending on your setup. If you're using AWS CLI and EC2-Classic, open your terminal and use the command:
aws ec2 release-address --public-ip <IP ADDRESS>
If you're using AWS CLI and EC2-VPC, use:
aws ec2 release-address --allocation-id <ALLOCATION ID>
If you're using AWS Tools for Windows PowerShell and EPC-Classic, open PowerShell and use the command:
Remove-EC2Address -PublicIp <IP ADDRESS> -Force
If you're using AWS Tools for Windows PowerShell and EPC-VPC, open PowerShell and use the command:
Remove-EC2Address -AllocationId eipalloc-<ALLOCATION ID> -Force
Now, you'll be able to track down and delete 3 of the most common unused AWS resources. If you do this on a regular cadence, you'll keep your resources organized and your costs down.
Top comments (0)