#!/usr/bin/env python3 """ rds-extended-support-check.py (CostFinch, https://costfinch.com/rds-extended-support) Lists every RDS and Aurora DB instance that is paying, or is about to pay, Amazon RDS Extended Support, and prices it with the AWS dates and list rates. READ-ONLY. The only AWS calls it makes are: sts:GetCallerIdentity which account you are looking at ec2:DescribeRegions only with --all-regions ec2:DescribeInstanceTypes vCPU count for each instance class rds:DescribeDBInstances the instances rds:DescribeDBClusters ACU range for Aurora serverless instances Nothing is written, changed, tagged or sent anywhere except those AWS APIs. The AWS managed ReadOnlyAccess policy covers all of them. Usage: pip install boto3 python3 rds-extended-support-check.py # current Region python3 rds-extended-support-check.py --all-regions python3 rds-extended-support-check.py --region us-east-1 --region eu-west-1 python3 rds-extended-support-check.py --all-regions --csv es.csv python3 rds-extended-support-check.py --profile prod --all-regions --json Rates default to the us-east-1 list price: $0.100 per vCPU-hour in years 1 and 2, $0.200 from year 3; Aurora serverless $0.085 and $0.170 per ACU-hour. Most other Regions cost more: pass your own with --rates v12,v3,a12,a3. Engine dates: AWS release calendars, checked 15 November 2026. If a date here disagrees with AWS, AWS wins. MIT License. Copyright (c) 2026 CostFinch. """ import argparse import csv import datetime as dt import json import re import sys try: import boto3 from botocore.exceptions import BotoCoreError, ClientError except ImportError: # pragma: no cover sys.exit("This script needs boto3: pip install boto3") CALENDAR_CHECKED = "2026-11-15" HOURS_PER_MONTH = 730 # id: (label, standard support ends, year 1 rate from, year 3 rate from, Extended Support ends) CALENDAR = { "rds-mysql-5.7": ("RDS for MySQL 5.7", "2024-02-29", "2024-03-01", "2026-03-01", "2029-06-30"), "rds-mysql-8.0": ("RDS for MySQL 8.0", "2026-07-31", "2026-08-01", "2028-08-01", "2029-07-31"), "rds-mysql-8.4": ("RDS for MySQL 8.4", "2029-07-31", "2029-08-01", "2031-08-01", "2032-07-31"), "rds-pg-11": ("RDS for PostgreSQL 11", "2024-02-29", "2024-04-01", "2026-04-01", "2027-03-31"), "rds-pg-12": ("RDS for PostgreSQL 12", "2025-02-28", "2025-03-01", "2027-03-01", "2028-02-29"), "rds-pg-13": ("RDS for PostgreSQL 13", "2026-02-28", "2026-03-01", "2028-03-01", "2029-02-28"), "rds-pg-14": ("RDS for PostgreSQL 14", "2027-02-28", "2027-03-01", "2029-03-01", "2030-02-28"), "rds-pg-15": ("RDS for PostgreSQL 15", "2028-02-29", "2028-03-01", "2030-03-01", "2031-02-28"), "aurora-mysql-2": ("Aurora MySQL 2 (MySQL 5.7)", "2024-10-31", "2024-12-01", "2026-12-01", "2029-06-30"), "aurora-mysql-3": ("Aurora MySQL 3 (MySQL 8.0)", "2028-04-30", "2028-05-01", None, "2029-07-31"), "aurora-pg-11": ("Aurora PostgreSQL 11", "2024-02-29", "2024-04-01", "2026-04-01", "2027-03-31"), "aurora-pg-12": ("Aurora PostgreSQL 12", "2025-02-28", "2025-03-01", "2027-03-01", "2028-02-29"), "aurora-pg-13": ("Aurora PostgreSQL 13", "2026-02-28", "2026-03-01", "2028-03-01", "2029-02-28"), "aurora-pg-14": ("Aurora PostgreSQL 14", "2027-02-28", "2027-03-01", "2029-03-01", "2030-02-28"), "aurora-pg-15": ("Aurora PostgreSQL 15", "2028-02-29", "2028-03-01", "2030-03-01", "2031-02-28"), } # Used only when ec2:DescribeInstanceTypes does not know a DB class. SIZE_VCPU = { "micro": 2, "small": 2, "medium": 2, "large": 2, "xlarge": 4, "2xlarge": 8, "4xlarge": 16, "8xlarge": 32, "12xlarge": 48, "16xlarge": 64, "24xlarge": 96, "32xlarge": 128, "48xlarge": 192, } def parse_date(s): return dt.date.fromisoformat(s) if s else None def calendar_id(engine, version): """Map an RDS engine and EngineVersion to a CALENDAR key, or None.""" key = _calendar_key(engine, version) return key if key in CALENDAR else None def _calendar_key(engine, version): m = re.match(r"(\d+)\.(\d+)", version or "") if not m: return None major, minor = m.group(1), m.group(2) if engine == "mysql": return "rds-mysql-%s.%s" % (major, minor) if engine == "postgres": return "rds-pg-%s" % major if engine == "aurora-mysql": return {"5.7": "aurora-mysql-2", "8.0": "aurora-mysql-3"}.get("%s.%s" % (major, minor)) if engine == "aurora-postgresql": return "aurora-pg-%s" % major return None def rate_on(cal_id, day, serverless, rates): """Hourly Extended Support rate per vCPU (or ACU) for this version on this day.""" _label, _std, y1, y3, end = CALENDAR[cal_id] y1, y3, end = parse_date(y1), parse_date(y3), parse_date(end) if day < y1 or (end and day > end): return 0.0 year3 = y3 is not None and day >= y3 if serverless: return rates["a3"] if year3 else rates["a12"] return rates["v3"] if year3 else rates["v12"] def status_on(cal_id, day): _label, std, y1, y3, end = CALENDAR[cal_id] y1, y3, end = parse_date(y1), parse_date(y3), parse_date(end) if day < y1: return "standard support", y1, "charges start" if end and day > end: return "Extended Support ended", None, "" if y3 is not None and day >= y3: return "Extended Support, year 3 rate", end, "Extended Support ends" if y3 is not None: return "Extended Support, year 1-2 rate", y3, "rate doubles" return "Extended Support, year 1-2 rate", end, "Extended Support ends" class VcpuLookup: def __init__(self, ec2): self.ec2 = ec2 self.cache = {} def __call__(self, db_class): if db_class in self.cache: return self.cache[db_class] ec2_type = db_class[3:] if db_class.startswith("db.") else db_class vcpu = None try: resp = self.ec2.describe_instance_types(InstanceTypes=[ec2_type]) types = resp.get("InstanceTypes", []) if types: vcpu = types[0]["VCpuInfo"]["DefaultVCpus"] except (ClientError, BotoCoreError): vcpu = None if vcpu is None: vcpu = SIZE_VCPU.get(ec2_type.rsplit(".", 1)[-1]) self.cache[db_class] = vcpu return vcpu def scan_region(session, region, today, rates): rds = session.client("rds", region_name=region) vcpus = VcpuLookup(session.client("ec2", region_name=region)) clusters = {} for page in rds.get_paginator("describe_db_clusters").paginate(): for c in page.get("DBClusters", []): clusters[c["DBClusterIdentifier"]] = c rows = [] for page in rds.get_paginator("describe_db_instances").paginate(): for db in page.get("DBInstances", []): cal_id = calendar_id(db.get("Engine"), db.get("EngineVersion")) if cal_id is None: continue db_class = db.get("DBInstanceClass", "") serverless = db_class == "db.serverless" cluster_id = db.get("DBClusterIdentifier") # A Multi-AZ instance (not a cluster member) bills its standby too. copies = 2 if (db.get("MultiAZ") and not cluster_id) else 1 if serverless: cfg = clusters.get(cluster_id, {}).get("ServerlessV2ScalingConfiguration", {}) lo, hi = cfg.get("MinCapacity"), cfg.get("MaxCapacity") units = float(lo or 0.5) unit_text = "%s to %s ACU" % (lo, hi) if lo is not None else "ACU unknown" else: per = vcpus(db_class) units = float((per or 0) * copies) unit_text = ("%d vCPU" % units) if per else "vCPU unknown" if copies == 2: unit_text += " (Multi-AZ)" state, next_date, next_what = status_on(cal_id, today) now_rate = rate_on(cal_id, today, serverless, rates) next_month = None if next_date and next_what in ("charges start", "rate doubles"): next_month = rate_on(cal_id, next_date, serverless, rates) * units * HOURS_PER_MONTH year = sum( rate_on(cal_id, today + dt.timedelta(days=i), serverless, rates) * units * 24 for i in range(365) ) rows.append({ "region": region, "db_instance": db.get("DBInstanceIdentifier"), "cluster": cluster_id or "", "engine_version": "%s %s" % (db.get("Engine"), db.get("EngineVersion")), "calendar": CALENDAR[cal_id][0], "class": db_class, "billed": unit_text, "status": state, "db_status": db.get("DBInstanceStatus", ""), "lifecycle_setting": db.get("EngineLifecycleSupport", ""), "monthly_now": round(now_rate * units * HOURS_PER_MONTH, 2), "next_change": ("%s %s" % (next_what, next_date.isoformat())) if next_date else "", "monthly_after_next": round(next_month, 2) if next_month is not None else "", "next_12_months": round(year, 2), }) return rows def money(x): return "$" + format(int(round(x)), ",") def print_table(rows): cols = [("region", "Region"), ("db_instance", "DB instance"), ("calendar", "Version"), ("class", "Class"), ("billed", "Billed"), ("status", "Status"), ("monthly_now", "Now /mo"), ("next_change", "Next change")] shown = [] for r in rows: line = dict(r) line["monthly_now"] = money(r["monthly_now"]) if r["db_status"] != "available": line["status"] = "%s [%s]" % (r["status"], r["db_status"]) shown.append(line) widths = [max(len(h), *(len(str(s[k])) for s in shown)) for k, h in cols] print(" ".join(h.ljust(w) for (_, h), w in zip(cols, widths))) print(" ".join("-" * w for w in widths)) for s in shown: print(" ".join(str(s[k]).ljust(w) for (k, _), w in zip(cols, widths))) def main(argv=None): ap = argparse.ArgumentParser(description="Read-only RDS Extended Support exposure check.") ap.add_argument("--profile") ap.add_argument("--region", action="append", help="Region to scan; repeat or comma-separate") ap.add_argument("--all-regions", action="store_true", help="Scan every Region enabled in the account") ap.add_argument("--rates", help="v12,v3,a12,a3 hourly rates (default 0.100,0.200,0.085,0.170)") ap.add_argument("--csv", help="Also write the rows to this CSV file") ap.add_argument("--json", action="store_true", help="Print JSON instead of a table") ap.add_argument("--today", help=argparse.SUPPRESS) args = ap.parse_args(argv) rates = {"v12": 0.100, "v3": 0.200, "a12": 0.085, "a3": 0.170} if args.rates: parts = [float(x) for x in args.rates.split(",")] if len(parts) != 4: ap.error("--rates needs four numbers: v12,v3,a12,a3") rates = dict(zip(("v12", "v3", "a12", "a3"), parts)) today = dt.date.fromisoformat(args.today) if args.today else dt.datetime.now(dt.timezone.utc).date() session = boto3.Session(profile_name=args.profile) if args.all_regions: ec2 = session.client("ec2", region_name=session.region_name or "us-east-1") regions = sorted(r["RegionName"] for r in ec2.describe_regions()["Regions"]) elif args.region: regions = [x.strip() for r in args.region for x in r.split(",") if x.strip()] else: regions = [session.region_name or "us-east-1"] try: account = session.client("sts").get_caller_identity()["Account"] except (ClientError, BotoCoreError): account = "unknown" rows, skipped = [], [] for region in regions: try: rows.extend(scan_region(session, region, today, rates)) except (ClientError, BotoCoreError) as e: skipped.append("%s: %s" % (region, e)) running = [r for r in rows if r["db_status"] != "stopped"] paying_now = sum(r["monthly_now"] for r in running) next_year = sum(r["next_12_months"] for r in running) if args.json: print(json.dumps({"account": account, "date": today.isoformat(), "rates": rates, "calendar_checked": CALENDAR_CHECKED, "instances": rows, "monthly_now": round(paying_now, 2), "next_12_months": round(next_year, 2), "skipped": skipped}, indent=2)) else: print("Account %s, %d Region(s), %s. Calendar checked %s." % ( account, len(regions), today.isoformat(), CALENDAR_CHECKED)) print() if rows: print_table(rows) else: print("No MySQL, PostgreSQL or Aurora instances with a published Extended Support date.") print() print("Extended Support now: %s a month (%s a year at today's rate)" % ( money(paying_now), money(paying_now * 12))) print("Next 12 months: %s, including every price change in that window" % money(next_year)) stopped = len(rows) - len(running) if stopped: print("Stopped instances: %d listed, not counted. RDS restarts a stopped " "instance after 7 days." % stopped) if any(r["class"] == "db.serverless" for r in rows): print("Aurora serverless: priced at the minimum ACU; real usage is usually higher.") print("On top of normal instance charges. Reserved Instances do not discount it.") for s in skipped: print("Skipped %s" % s, file=sys.stderr) print() print("Every instance across all your accounts, priced and in upgrade order: " "https://costfinch.com/scan") if args.csv: with open(args.csv, "w", newline="") as f: w = csv.DictWriter(f, fieldnames=list(rows[0].keys()) if rows else ["db_instance"]) w.writeheader() w.writerows(rows) return 0 if __name__ == "__main__": sys.exit(main())