-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
31 lines (23 loc) · 940 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import boto3
from iam_users import key_disabler
from ses_notification import notification
ses_client = boto3.client("ses", region_name="us-west-2", aws_access_key_id=os.environ['ACCESS_KEY'], aws_secret_access_key=os.environ['SECRET_ACCESS_KEY'])
users_list = key_disabler.get_iam_user()
print("Warning List")
warn_list = key_disabler.get_warning_users_list(users_list)
print("Danger List")
dang_list = key_disabler.get_disable_users_list(users_list)
users_data = warn_list + dang_list
def ses_mail(source="[email protected]",to="[email protected]"):
response = ses_client.send_email(
Source=source,
Destination={
'ToAddresses': [
to,
]
},
Message=notification.compose_mail_for_admins(users_data)
)
print(response)
ses_mail(source=os.getenv("SOURCE_ADDR", default="[email protected]"),to=os.getenv("TO_ADDR",default="[email protected]"))