Pramod Gaikwad Pramod Gaikwad - 6 months ago 44
Java Question

How to get AWS account details using java api? Not for IAM user

We have two AWS accounts. One is for production and another is for testing. We need to differentiate the environment we are running. We can see that a simple way is to get account name and once we get that it will be very straight forward. But, we don't know how to get it from AWS credentials or properties. Does anyone have idea about how to get account information using AWS credentials?
I considered the possibility of account permissions, account type etc, but I think it should not prevent us from getting account name?

Answer

You can see the GetUserResult. This is returned by getUser(). GetUserResult has a method to get User. This User has all the fields to get the required information you need.

Comments