'How to convert the AWS S3 principalId to user name

"userIdentity":{  
    "principalId":"Amazon-customer-ID-of-the-user-who-caused-the-event"
 },

How I can convert the principal id, which is available with S3 Event Notification, into the user Name which is responsible for the action?



Solution 1:[1]

I couldn't find how to do this either. I ended up sending the sub from user attributes as part of the object key. Then you have access to the sub in the event notification.

Solution 2:[2]

It's mind-boggling why the IAM console UI does not show this nor allow for searching.

Have to use the AWS CLI to pull out these info.

aws iam list-users

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 Timmy
Solution 2 icelava