blob: cd0d3a03c7858c979932cd44fd71e91885d52425 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
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)
|