DEV Community

Ace7-coder
Ace7-coder

Posted on

AWS FinOps Field Notes: DynamoDB Underutilized Provisioned Capacity

While auditing cloud infrastructure costs this week, recurring configuration gaps continue to quietly inflate monthly bills.

Field Insight: The Hidden Cost Trap

Provisioned capacity costs $0.00065/WCU-hour ($0.47/month per WCU) and $0.00013/RCU-hour ($0.09/month per RCU), so a table statically provisioned for 1,000 WCU plus 2,000 RCU costs $664/month ($7,968/year). When CloudWatch ConsumedWriteCapacityUnits shows peak utilization under 5%, over $7,000/year is spent reserving idle throughput; converting to On-Demand (Pay-Per-Request at $1.25/million writes) or setting DynamoDB Auto Scaling with a 70% target utilization cuts the bill by 80%.

Automated Detection: Auditing DynamoDB Underutilized Provisioned Capacity with Boto3

import boto3
from datetime import datetime, timedelta, timezone

def audit_dynamodb_provisioned(region='us-east-1'):
    dynamodb = boto3.client('dynamodb', region_name=region)
    cw = boto3.client('cloudwatch', region_name=region)
    now = datetime.now(timezone.utc)
    one_day_ago = now - timedelta(days=1)

    tables = dynamodb.list_tables().get('TableNames', [])
    flagged = []
    for table in tables:
        desc = dynamodb.describe_table(TableName=table)['Table']
        billing = desc.get('BillingModeSummary', {}).get('BillingMode')
        if billing != 'PROVISIONED':
            continue
        throughput = desc.get('ProvisionedThroughput', {})
        wcu = throughput.get('WriteCapacityUnits', 0)
        rcu = throughput.get('ReadCapacityUnits', 0)
        monthly_cost = wcu * 0.47 + rcu * 0.09  # $0.47/WCU-mo, $0.09/RCU-mo
        res = cw.get_metric_statistics(
            Namespace='AWS/DynamoDB',
            MetricName='ConsumedWriteCapacityUnits',
            Dimensions=[{'Name': 'TableName', 'Value': table}],
            StartTime=one_day_ago,
            EndTime=now,
            Period=3600,
            Statistics=['Maximum']
        )
        points = res.get('Datapoints', [])
        peak = max((p['Maximum'] for p in points), default=0)
        peak_util = (peak / wcu * 100) if wcu else 0
        if peak_util < 5:
            flagged.append(table)
            print(f"[ALERT] {table}: {wcu} WCU + {rcu} RCU costs ${monthly_cost:.2f}/mo "
                  f"at {peak_util:.1f}% peak write utilization. "
                  f"Consider On-Demand or Auto Scaling.")
    return flagged

if __name__ == '__main__':
    audit_dynamodb_provisioned()
Enter fullscreen mode Exit fullscreen mode

Running ad-hoc scripts in a single account or region does not scale across enterprise AWS Organizations. Sustained cloud cost governance requires automated anomaly detection, cross-account STS role assumption, and scheduled auditing.

  • 📦 Download Free Single-Account Core: Free Lite Package | GitHub
  • 💼 Managing Multiple Accounts or Client Infrastructure?
    • Practitioner License ($99): Single-account CLI scanner, compliance exports, and dynamic bash remediation.
    • Consultancy & Agency Pack ($499): Automated multi-account STS role assumption, CloudFormation StackSets, and branded executive PDF showback reports.

👉 Get the AWS Cloud Cost Auditor on Gumroad

Top comments (0)