Whitepaper 'FinOps and cost management for Kubernetes'
Please consider giving OptScale a Star on GitHub, it is 100% open source. It would increase its visibility to others and expedite product development. Thank you!
Ebook 'From FinOps to proven cloud cost management & optimization strategies'
OptScale FinOps
OptScale — FinOps
FinOps overview
Cost optimization:
AWS
MS Azure
Google Cloud
Alibaba Cloud
Kubernetes
MLOps
OptScale — MLOps
ML/AI Profiling
ML/AI Optimization
Big Data Profiling
OPTSCALE PRICING
cloud migration
Acura — Cloud migration
Overview
Database replatforming
Migration to:
AWS
MS Azure
Google Cloud
Alibaba Cloud
VMWare
OpenStack
KVM
Public Cloud
Migration from:
On-premise
disaster recovery
Acura — DR & cloud backup
Overview
Migration to:
AWS
MS Azure
Google Cloud
Alibaba Cloud
VMWare
OpenStack
KVM

How to detect unattached volumes in AWS to stop paying for unused resources

Effective cloud cost management is a key priority for companies across all industries. It enables businesses to gain clear understanding, transparency and optimization of all costs associated with cloud infrastructure.

Problem description

The_best_way_to_detect_unattached_volumes_in_AWS_to_stop_paying

Lack of visibility into a volume lifecycle causes extra costs for unused and overlooked resources. For AWS customers unattached Elastic Block Storage (EBS) volumes can become a reason for unexpected charges in an AWS cloud bill. In some cases the lifecycle of EBS volumes persists even if an EC2 instance is terminated. Such unattached EBS volumes in AWS accounts aren’t used but you are still paying for them.

Our recommendations will help you identify overlooked unattached EBS volumes and delete them to optimize cloud costs and prevent underutilized resources.

Recommendations

Step 1

If we want to find all volumes, we should go over all available regions.
Aws cli command:

aws ec2 describe-regions --query "Regions[].RegionName" --output text

Step 2

For every available region we should go over all volumes and check the current status. If the current status is available, this volume is not attached to any instances.
Aws cli command:

aws ec2 describe-volumes --region "$region" --filters Name=status,Values=available --query 'Volumes[].[VolumeId]' --output text

Free cloud cost optimization. Lifetime

Note

Aws cli has a pagination mechanism for large amounts of data in output. If you have many volumes in a region, the provided script will process only the first page. Consider using something more powerful than aws cli.

As a result one line command:

for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do for volumeId in $(aws ec2 describe-volumes --region "$region" --filters Name=status,Values=available --query 'Volumes[].[VolumeId]' --output text); do echo "Region: $region VolumeId $volumeId"; done; done

Remainder

This script shows volumes which are not attached to any instances at this moment. It could be a temporary state, and it would be great to check the last attached date before deleting the volume. Unfortunately, aws doesn’t store a history of attachments. In that case you can use the following variants:

  1. Execute this script twice with one day delay and find volumes which are still not attached after a day.
  2. If your account has cloud trail logs enabled. You can try to find the last attachment date by this instruction https://aws.amazon.com/ru/premiumsupport/knowledge-center/list-attachments-history-ebs-volume/
  3. Using third-party tools like OptScale, FinOps and cloud cost management platform, can help you identify unattached EBS volumes and reduce costs in a couple of clicks

👆🏻 Storing objects in AWS S3 public buckets could threaten the security of your company data.

💡 Discover the recommendations, which help you manage public access to AWS S3 resources properly and ensure that all required buckets and objects have their public access blocked  → https://hystax.com/the-quickest-way-to-get-a-list-of-public-buckets-in-aws-to-enhance-your-security

Enter your email to be notified about new and relevant content.

Thank you for joining us!

We hope you'll find it usefull

You can unsubscribe from these communications at any time. Privacy Policy

News & Reports

FinOps and MLOps

A full description of OptScale as a FinOps and MLOps open source platform to optimize cloud workload performance and infrastructure cost. Cloud cost optimization, VM rightsizing, PaaS instrumentation, S3 duplicate finder, RI/SP usage, anomaly detection, + AI developer tools for optimal cloud utilization.

FinOps, cloud cost optimization and security

Discover our best practices: 

  • How to release Elastic IPs on Amazon EC2
  • Detect incorrectly stopped MS Azure VMs
  • Reduce your AWS bill by eliminating orphaned and unused disk snapshots
  • And much more deep insights

Optimize RI/SP usage for ML/AI teams with OptScale

Find out how to:

  • see RI/SP coverage
  • get recommendations for optimal RI/SP usage
  • enhance RI/SP utilization by ML/AI teams with OptScale