Skip to main content

🛡️ AWS EC2 Instance is idle🟢

Logic

Description

Open File

Description

Identify Amazon EC2 instances with minimal activity over the past 14 days and address them to reduce unnecessary costs. When a linked New Relic host is available, this policy combines CloudWatch CloudWatch: CPU, 14-Day and CloudWatch: CPU Max, 14-Day with New Relic memory, disk read utilization, and disk write utilization plus 14-day network metrics. Otherwise, it uses the existing CloudWatch CPU and network metrics. Instances are classified as idle if they meet the applicable criteria:

  • CPU utilization below 5%
  • Maximum CPU utilization below 15%
  • Memory utilization below 20%
  • Disk read utilization below 5%
  • Disk write utilization below 5%
  • 14-day network I/O below 100 MB

Rationale

Idle EC2 instances consume resources and incur costs without contributing meaningfully to operations. Adding maximum CPU utilization as a criterion ensures instances experiencing brief spikes in usage are not prematurely identified as idle. This approach improves accuracy in cost-saving measures while maintaining operational efficiency. Addressing idle instances reduces waste and optimizes the AWS environment.

... see more

Remediation

Open File

Remediation

IMPORTANT: Before taking any action, ensure critical data and configurations are backed up. Carefully evaluate idle instances to avoid disrupting essential workloads or losing valuable resources.

From Command Line

Stop Idle Instances
Prerequisites
  • Verify that the root device of the instance is an EBS volume. You can't stop instances with an instance store root device.

  • Warning: When you stop an instance, the data on any instance store volumes is erased. Before you stop an instance, verify that you've copied any data that you need from the instance store volumes to persistent storage, such as Amazon EBS or Amazon S3.

Stop idle instances to retain their configurations for potential future use:

aws ec2 stop-instances --instance-ids {{instance-id}}

If applicable, initiate hibernation using the --hibernate flag for On-Demand or Spot Instances. Hibernation is supported only for EBS-backed instances that are enabled for hibernation and meet the prerequisites. It saves the contents of RAM to the Amazon EBS root volume.

... see more

policy.yaml

Open File

Linked Framework Sections

SectionSub SectionsInternal RulesPoliciesFlagsCompliance
💼 Cloudaware Framework → 💼 Waste Reduction25no data
💼 Cloudaware Framework → 💼 Workload Efficiency24no data