【发布时间】:2018-09-30 19:16:07
【问题描述】:
我有一个 python 脚本,它在 AWS 中提供了最后一次登录的 IAM 用户名。我得到了预期的结果。现在我添加了 SNS 主题以通过电子邮件发送结果。 但我在电子邮件中收到的回复如下
回复:
User not logged into AWS:
u
s
e
r
n
a
m
e
:
我需要在单行中作为用户名:“*****”
PhysicalString =''
for user in resource.users.all():
if user.password_last_used is not None:
delta = (today - user.password_last_used.replace(tzinfo=None)).days
final_result=("username: ", [user.user_name][0]," - ",delta , "days")
physicalString = 'User not logged into AWS: \n\n' + '\n'.join(str(final_result))
response = sns.publish(
TopicArn='*************',
Message= physicalString,
Subject='IAM USER',
)
return final_result
【问题讨论】:
标签: python python-3.x amazon-web-services aws-lambda