diff options
Diffstat (limited to 'email_formatter.py')
-rw-r--r-- | email_formatter.py | 13 |
1 files changed, 13 insertions, 0 deletions
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) |