From 785f42901f34aaf356f316c691e3f56138c8608d Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Fri, 20 Jun 2025 13:55:54 -0500 Subject: initial commit --- email_formatter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 email_formatter.py (limited to 'email_formatter.py') diff --git a/email_formatter.py b/email_formatter.py new file mode 100644 index 0000000..cd0d3a0 --- /dev/null +++ b/email_formatter.py @@ -0,0 +1,13 @@ +def format_billing_info(results): + date = results["TimePeriod"]["Start"] + lines = [f"AWS Billing Report for {date}", "-" * 40] + + for group in results["Groups"]: + service = group["Keys"][0] + amount = group["Metrics"]["UnblendedCost"]["Amount"] + lines.append(f"{service:<30} ${float(amount):>10.2f}") + + total = results["Total"]["UnblendedCost"]["Amount"] + lines.append("-" * 40) + lines.append(f"{'TOTAL':<30} ${float(total):>10.2f}") + return "\n".join(lines) -- cgit v1.2.3-70-g09d2