'Aws S3 event, get user name
I have objects on S3 glacier deep archives. I want to send an email to the user who request the restoration when the restoration is complete.
For that, my idea is to use S3 event to trigger a lambda function, and use this lambda function to send email.
The issue is that i don't know how to found informations about the users who request the restoration. I found the id, but then, how to use the id ? If i have the username i Can easly found tag associated with this username (and so, the email adress as it's a tag of my users) but i don't know how to use the id to found the username.
If someone has an Idea ?
Solution 1:[1]
Finally i found a solution, i don't know if it's the best, but at least it work for me: As all my users as a tag "mail_adress" i can search this tag from the user id with this code:
import boto3
iam = boto3.client('iam')
response = iam.get_account_authorization_details(Filter=['User'])
for i in range(len(response['UserDetailList'])):
if response['UserDetailList'][i]['UserId'] == id_user:
for y in range(len(response['UserDetailList'][i]['Tags'])):
if response['UserDetailList'][i]['Tags'][y]['Key'] == 'mail_adress':
mail_adresse = response['UserDetailList'][i]['Tags'][y]['Value']
print(mail_adress)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Quentin Chartreux |
