how to know IAM user is admin or not in Java
Hi Team, With the help of java aws sdk, I can create AmazonIdentityManagementClient IAM object. And also I can get all the list of users those are associated with this aws account. Now I want to know that what all users are admin. How can I do this with the help of java aws sdk?
I've got Ruby code working. The secret is that you have to look at both the user's policies and managed policies, and if the policy name matches AdministratorAccess, they are an administrator. I'll talk to the Java SDK writer and see if she can add porting the Ruby code to her doc to-do list.
Doug's suggestion is definitely valid, but I don't think that will give you an exhaustive list of everyone with administrator permissions. Permissions can come from a large variety of policies, and they might not all be named in a way that indicates "administrator" type access. You could even have an embedded (not managed) policy attached to a user that says effectively "Allow : on resources:*" - that is effectively an admin as well.
I think your best option is to determine which specific APIs would make a user an Admin when granted to that user. For example, many of the IAM permissions would fall into this category. Once you have that list, use them with the Policy Simulator APIs to determine whether a user has one or more of those permissions. See: https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulatePrincipalPolicy.html and https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulateCustomPolicy.html for details of how to run them. You can call them from any of the SDKs as well.
I hope this helps! Dave
I'm going to close this as it seems the user's request has been met.