Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically determine AWS account Id of a particular IAM user

I have a web tool which allows IAM users to do magic with their AWS account. Considering I have a free plan, any AWS user could create new IAM users once the trial has ended, so they would eventually never pay for my service. Is there any way to know the Aws Account Id of a particular IAM user? That way I can store that ID on db and block any other new IAM user coming from that particular AWS account.

like image 540
alexandresaiz Avatar asked Feb 10 '23 14:02

alexandresaiz


1 Answers

From CLI

aws sts get-caller-identity

If you use IAM based calls (same as what other people suggested) your IAM user needs to have proper permissions for those calls but sts one should go through for any IAM user.

like image 69
Arash Avatar answered Apr 06 '23 06:04

Arash