- Newest
- Most votes
- Most comments
Hello,
There is no native solution as such but, there is a solution that is published by AWS for a similar scenario. You might want to take a look at Instance scheduler:
[+] https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/
However, it also depends on what you mean by "have not been used". I have a set up in my account that uses AWS Lambda, Boto3 SDK and DynamoDB. The workflow is as follows:
- A lambda function runs through the account and collects details about all active resources on the account every 1 hour except that have a special tag to exclude them.
- This information is stored in DynamoDB table
- Another lambda function reviews the data in the DDB table and evaluates against pre-defined rules. For example, all EC2 instances that have an average CPU utilization of less than 1% over 24 data points stored in the DDB table to be stopped.
- Another lambda function evaluates the DDB items and performs necessary action such as stop/delete the resource.
I'm interested in how this would exclude instances with a special tag. Do you have copies of the Lambda function in step 1 that you can share?
We would need to send an SNS to the account owner tag attached to the instance. Could this be done in the Lambda function in step 4?
AWS Trusted Advisor has a check, Low Utilization Amazon EC2 Instances, under Cost Optimizations, that will alert when:
An instance had 10% or less daily average CPU utilization and 5 MB or less network
I/O on at least 4 of the previous 14 days.
These events are sent to Amazon EventBridge and you can create a rule to trigger an action, like an email from an SNS topic or a invoke a lambda function.
You can also turn on an Organization view of Trusted Advisor.
Relevant content
- asked 2 months ago
- asked 6 years ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 3 years ago

To get a further understanding, what does it mean by being used? Processes run? User accessing? Any other metric?