my requirement is, my code will be deployed on an ec2 instance. and at some point, it needs the username of the IAM account who is executing that code. or whose session is currently active on that ec2 instance. Is it even possible?
FYI, I read the answers here From AWS SDK, how to I get the current logged in username (or IAM user)?, but they are not much of a use
PS. I have to authenticate which IAM account is executing the spark job
Edit: based on @John Rotenstein suggestions, adding more details
Many IAM users might access the ec2 instance when provided with IP. So based on which IAM users has logged in into EC2 instance, and is trying to run spark job
in an EMR
cluster. I want to validate if he has permission to execute the code ( There is a separate database of list of authorized users, where i would search his IAM username in database, if not found throw an error). For this purpose, i need the username of that IAM account.
If there is any utility in aws-sdk or some kind of metadata which gets created after a IAM user launches ec2 instance? And just for clarity, I know the details of os users, and not concerned with them. Till now, we were doing this process with os users only, but with new changes we need to validate users from their IAM account username instead of os usernames.