diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-06-20 13:55:54 -0500 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2025-06-20 13:55:54 -0500 |
commit | 785f42901f34aaf356f316c691e3f56138c8608d (patch) | |
tree | 5b8f7a6e33a6af410e511137fdd51b6fa60d0f83 /email_formatter.py | |
download | aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.tar.gz aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.tar.bz2 aws-summary-report-785f42901f34aaf356f316c691e3f56138c8608d.zip |
initial commit
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) |