Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the instance_type to report #684

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cloudsensei/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change the order also here 'InstanceType' before 'RunningDays' ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, It is the data storing/ returning variable.

return long_running_instances_by_user

def get_account_alias_name(self):
Expand All @@ -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():
Expand All @@ -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})
Expand Down
Loading