From d50e72490c702d740668a369195022822251fea6 Mon Sep 17 00:00:00 2001 From: Thirumalesh Aaraveti Date: Mon, 9 Oct 2023 17:29:46 +0530 Subject: [PATCH] Added the instance_type to report --- cloudsensei/lambda_function.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cloudsensei/lambda_function.py b/cloudsensei/lambda_function.py index 0fda44f8..de97a85d 100644 --- a/cloudsensei/lambda_function.py +++ b/cloudsensei/lambda_function.py @@ -77,7 +77,8 @@ def get_resources(self): long_running_instances_by_user.setdefault(user.lower(), {}).setdefault(region_name, []).append( {'InstanceId': resource.get('InstanceId'), 'Name': name, 'LaunchDate': str(launch_time), - 'RunningDays': f"{days} days", 'State': resource.get('State', {}).get('Name')}) + 'RunningDays': f"{days} days", 'State': resource.get('State', {}).get('Name'), + 'InstanceType': resource.get('InstanceType')}) return long_running_instances_by_user def get_account_alias_name(self): @@ -97,7 +98,7 @@ def organize_message_to_send_slack(self, resources_list: dict): """ divider = {"type": "divider"} - keys_list = ['User', 'Region', 'Name', 'InstanceId', 'LaunchDate', 'RunningDays'] + keys_list = ['User', 'Region', 'Name', 'InstanceType', 'InstanceId', 'LaunchDate', 'RunningDays'] rows = [] for user, region_list in resources_list.items(): for region_name, resources_list in region_list.items(): @@ -121,7 +122,7 @@ def organize_message_to_seng_mail(self, resources_list: dict): :param resources_list: :return: """ - keys_list = ['User', 'Region', 'Name', 'InstanceId', 'LaunchDate', 'State', 'RunningDays'] + keys_list = ['User', 'Region', 'Name', 'InstanceType', 'InstanceId', 'LaunchDate', 'State', 'RunningDays'] with open('email_template.j2') as template: template = Template(template.read()) body = template.render({'resources_list': resources_list, 'keys_list': keys_list})