On AWS, you will experiment a lot. It is one of the main advantage of the Cloud Computing.
To level up your skills following a training (maybe a certification path), testing something new, working on a Proof of Concept (PoC) for your products and side-projects, automating a painful task, or experimenting with some new fancy 🤖 AI - ML - LLM things.
As you all know, the Cloud Service Provider (CSP) pricing is using the consumption-based model, so everything active will be billed at the end of the month. 💣
It is frequent and normal to forget to turn things off (I'm doing this all the time) or be conscious that there are still resources up and running on your account, especially if you are a newcomer.
You must manually check billing services like AWS Cost Explorer to verify that nothing is ramping up your bill and worth, there are no built-in default billing alerts, you have to setup yourself.
It is even more challenging that there are 23 regions (to date) where your assets can reside over the AWS global footprint.
In this blog post, we will share a methodology for the most common AWS services (usual suspects) to identify if there are wasted resources on your AWS account and ultimately:
- Save Money
- Reduce Attack Surface
- Lower Carbon Footprint
Let's dive into the main culprit AWS services 🔍
🖥️ EC2 Instances
To find unused AWS instances, you will need to rely on CloudWatch (CW) metrics. At a starting point, we can rely on the following metrics: CPUUtilization, and NetworkPacketsIn / NetworkPacketsOut. Our assumption here is, if the CPU Utilization is barely low AND there is no traffic in / out during a specific period, we can assume this EC2 instance is not used anymore.
Great way to achieve this kind of monitoring is to monitor multiple CW metrics with for example Composite Alarm.
To check Underutilized instances, you can also review it manually each instance in EC2 Console and check the Monitoring tab in the last two weeks period for example.
There is also some paid options on AWS:
- Trusted Advisor: Cost Optimizations section (Business or Enterprise Support Plan required - at least $100/month)
- AWS Compute Optimizer (See Pricing)
💽 RDS Instances
CloudWatch Metrics to see active connection to RDS Database.
We assume that a db without any connection for a week is a good suspect for not being used anymore. Operational teams will need to confirm this assumption.
The corresponding CloudWatch Metric is: DatabaseConnections you can either check the history of this metric using API or by looking it into CloudWatch Console.
To monitor this assumption on your AWS account, you can setup a CloudWatch alarm to monitor this behavior with an alarm on a 0 threshold on this metric for a period of one week.
Here is a CloudFormation to setup this Alarm:
🪣 EBS Volumes
For EBS Volumes, in some cases, the volume could be detached or available, so there are no more active ones, and no EC2 instance could use it. It could be legit, but in most cases, its no longer used, and as a preventive measure, when you terminate an EC2, the attached disk is just detached.
The following command will help you to identify “available” EBS volumes for a given AWS Region.
📸 EBS Snapshots
Sometimes, you create a snapshot of a specific volume and keep it forever. But it costs you money. Generally, we assume snapshots older than 90 days are irrelevant and useless.
To identify these obsolete snapshots, run the bash script below for a given AWS Region.
There are some AWS services that, when you delete them, will create a termination snapshot as a safety procedure, but the snapshot will reside here forever (and billed forever).
📒 CloudWatch LogGroups
CloudWatch LogGroup can also be stored indefinitely (default behavior). This will lead to a subsequent amount of wasted dollars on your AWS bills.
To identify CloudWatch LogGroup without expiration, you can run the following AWS CLI command:
👷🏻♀️ IAM Principals
One way to extract last usage of IAM principals is to rely on credential report. If you are not familiar with this generated csv file, its a flat file that contains all AWS users with many metadata about the IAM creds. Generally its used during habilitations reviews.
For IAM Roles, its harder, you will have to generate a report for each role.
I Don't Have Time. Can This Be Automated?
Navigating the labyrinth of waste detection on your AWS account can be a time-consuming endeavor, especially when the landscape is ever-changing and geographically spread across multiple AWS regions. It's not just a one-time task; it requires ongoing diligence to spot unused or underutilized assets systematically.
Moreover, the scope of potential wastage extends beyond the common AWS services we've discussed here. It seeps into specialized services such as Redshift Clusters, Glue Endpoints, SageMaker Apps, Notebooks or Endpoints.
That's where unusd.cloud comes into play.
Within minutes, you can onboard your AWS accounts onto our SaaS platform. You can then schedule regular scans across all accounts and regions, effectively automating the waste-detection process.
No more manual sifting through CloudWatch metrics or setting up ad-hoc alerts. Our solution does the heavy lifting for you, offering you peace of mind and more time to focus on strategic cloud initiatives.
You'll receive a digest report through your communication channel of choice—be it Email, Microsoft Teams, or Slack. This ensures that your operational teams can continue to work within their existing Instant Messaging tools, seamlessly integrating waste management into their daily routines and discussions.