Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a user's s3 canonical ID from the command line?

I'm creating special-purpose users for Amazon S3 access, for example to give out to a third-party service. The accounts don't have an email address or password. I was hoping I'd be able to pull the canonical ID of these accounts using the aws command-line tool.

One way I have read about is to create a bucket using their account, look at the acl for it, and extract the canonical ID from that, then delete the useless bucket and move on.

But for future use, is there an easier way?

like image 515
Dobes Vandermeer Avatar asked Sep 10 '14 19:09

Dobes Vandermeer


1 Answers

If you run:

aws iam list-users 

You get a list of all of your IAM users. One of the fields is UserId, which is defined as "The stable and unique string identifying the user".

If that is what you are looking for, then you can retrieve it with:

aws iam get-user --user-name <iam user name> --query 'User.UserId'
like image 118
chris Avatar answered Nov 10 '22 03:11

chris