turbot/aws_thrifty
Loading controls...

Control: RDS DB instances with a low number connections per day should be reviewed

Description

DB instances having less usage in last 30 days should be reviewed.

Usage

Run the control in your terminal:

powerpipe control run aws_thrifty.control.rds_db_low_connection_count

Snapshot and share results via Turbot Pipes:

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

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1rds_db_instance_avg_connections
2
The minimum number of average connections per day required for DB instances to be considered in-use.

SQL

with rds_db_usage as (
select
db_instance_identifier,
round(sum(maximum) / count(maximum)) as avg_max,
count(maximum) days
from
aws_rds_db_instance_metric_connections_daily
where
date_part('day', now() - timestamp) <= 30
group by
db_instance_identifier
)
select
arn as resource,
case
when avg_max is null then 'error'
when avg_max = 0 then 'alarm'
when avg_max < $1 then 'info'
else 'ok'
end as status,
case
when avg_max is null then 'CloudWatch metrics not available for ' || title || '.'
when avg_max = 0 then title || ' has not been connected to in the last ' || days || ' days.'
else title || ' is averaging ' || avg_max || ' max connections/day in the last ' || days || ' days.'
end as reason,
region,
account_id
from
aws_rds_db_instance i
left join rds_db_usage as u on u.db_instance_identifier = i.db_instance_identifier;

Tags