Is it possible to get the canonical user id from AWS IAM users, from the .NET API?


I have successfully created a user, credentials, and a bucket.
Now I need to grant bucket access to this user.

Is there any way to get this CanonicalUser value from code?
The IAM user object only provides ARN, Path, UserId and UserName values, but none of these are valid for the grant.


You can easily get CanonicalUser ID using ListAllMyBuckets API call [1] (s3:ListAllMyBuckets permission is required):

In AWS SDK for .NET, use code like this [2]:

In AWSJavaSDK you can use AmazonS3.getS3AccountOwner wrapper method [3].


Leave a Reply