turbot/oci_thrifty
Loading controls...

Control: Long running compute 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 oci_thrifty.control.compute_instance_long_running

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run oci_thrifty.control.compute_instance_long_running --share

Steampipe Tables

Params

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

SQL

select
a.id as resource,
case
when a.lifecycle_state <> 'RUNNING' then 'skip'
when date_part('day', now() - a.time_created) > $1 then 'alarm'
else 'ok'
end as status,
case
when a.lifecycle_state <> 'RUNNING' then a.title || ' in ' || a.lifecycle_state || ' state.'
else a.title || ' has been running ' || date_part('day', now() - a.time_created) || ' days.'
end as reason,
coalesce(c.name, 'root') as compartment,
a.region
from
oci_core_instance as a
left join oci_identity_compartment as c on c.id = a.compartment_id;

Tags