turbot/aws_thrifty
Loading controls...

Control: Long running EC2 instances should be reviewed

Description

Instances should ideally be ephemeral and rehydrated frequently, check why these instances have been running for so long.

Usage

Run the control in your terminal:

powerpipe control run aws_thrifty.control.long_running_ec2_instances

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run aws_thrifty.control.long_running_ec2_instances --share

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1ec2_running_instance_age_max_days
90
The maximum number of days instances are allowed to run.

SQL

select
arn as resource,
case
when date_part('day', now() - launch_time) > $1 then 'alarm'
else 'ok'
end as status,
title || ' has been running ' || date_part('day', now() - launch_time) || ' days.' as reason,
region,
account_id
from
aws_ec2_instance
where
-- Instance is running
instance_state in ('running', 'pending', 'rebooting');

Tags