- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
11-22-2019 04:22 PM - last edited on 09-02-2020 11:08 AM by CHopson
Hi,
Can someone help me with an RQL to display the list of Users, policies attached, and the actions allowed in the policies.
I want to be able to export this into a CSV. Any help here is much appreciated.
Thanks,
Sultan
12-02-2019 08:14 AM
This should get you what you are looking for (you were missing the brackets for the array (attachedPolicies):
config where api.name = 'aws-iam-list-attached-user-policies' as X; config where api.name = 'aws-iam-get-policy-version' as Y; filter "$.X.attachedPolicies[*].policyArn==$.Y.policyArn and $.Y.document.Statement[?(@.Effect=='Allow')].Action is not empty"; show Y;
11-25-2019 09:46 AM - edited 11-25-2019 09:46 AM
Hi Sultan,
What cloud provider are you trying to pull a list of users for?
Thanks,
Eddie
11-26-2019 06:52 AM
Hi Eddie,
I would like to output the list of AWS IAM users, the policies attached to each user, and the list of Actions that they're allowed. If this could be displayed in three different columns, that would be great!
Thanks in advance,
Sultan
11-26-2019 07:37 AM
So users can have inline policies as well as attached policies. It would be difficult to show it all in one pane due to the joins that would need to be used. Do you only want to list users that have inline or attached policies? Or a complete list of users regardless of policies?
Thanks,
Eddie
11-27-2019 01:52 PM
If space is a constraint, we can do it two iterations. First one shows all the users with attached policies and the actions allowed. Second shows all the users with inline policies and actions allowed.
How's this to begin with?.. but no luck though.. 😕
config where api.name = 'aws-iam-list-attached-user-policies' as X; config where api.name = 'aws-iam-get-policy-version' as Y; filter "$.X.attachedPolicies.policyArn==$.Y.policyArn and $.Y.document.Statement[?(@.Effect == 'Allow' && @.Action is not empty]; show Y;
12-02-2019 08:14 AM
This should get you what you are looking for (you were missing the brackets for the array (attachedPolicies):
config where api.name = 'aws-iam-list-attached-user-policies' as X; config where api.name = 'aws-iam-get-policy-version' as Y; filter "$.X.attachedPolicies[*].policyArn==$.Y.policyArn and $.Y.document.Statement[?(@.Effect=='Allow')].Action is not empty"; show Y;
12-02-2019 08:56 AM
Eddie,
Thank you, this is helpful. But how can I list all the allowed actions in the form of a column. My end goal is to export this to a CSV which shows all the user policies and actions it allows. Currently, if I were to export it, the output doesn't display the list of actions allowed.
12-02-2019 10:28 AM
You won't be able to do that within the UI due to the sheer number of actions that could be returned. I would suggest using our API to pull the data you want and export it into CSV format.
Thanks,
Eddie
12-02-2019 10:29 AM
Thanks Eddie. That makes sense!
12-06-2019 11:47 PM
Hi ,
I believe it will show only the first case that attached policies with action only.Not inline policy details with action.Also please help me to understand where it's showing list of user names and respective policy details and action details.The report is showing only list of policy details not even action??
Please correct me if i am wrong??
Thank you.
12-06-2019 11:47 PM
Hi Eddy,
Hi ,
I believe it will show only the first case that attached policies with action only.Not inline policy details with action.Also please help me to understand where it's showing list of user names and respective policy details and action details.The report is showing only list of policy details not even action??
Please correct me if i am wrong??
Thank you.
12-08-2019 12:09 PM
Yes, as I mentioned earlier, you would need two RQL statements to get you both inline and attached. To get the username and specific items you are looking for, you would need to use an API call with some filtering with a scripting language like python.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!