From 7220cab8899df0ae7f867468b9a6690f2f4178c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r?= Date: Tue, 24 May 2022 23:35:02 +0200 Subject: [PATCH] Handle missing name --- handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler.py b/handler.py index 9b93d2c..9bee2d6 100644 --- a/handler.py +++ b/handler.py @@ -83,10 +83,10 @@ def report_cost(group_by: str = "SERVICE", length: int = 5, result: dict = None, if "AccountAliases" in aliases and len(aliases["AccountAliases"]) > 0: account_name = aliases["AccountAliases"][0] - if account_name is None: + if account_name is None or account_name == "": account_name = boto3.client("sts").get_caller_identity().get("Account") - if account_name is None: + if account_name is None or account_name == "": account_name = "[NOT FOUND]" client = boto3.client('ce')