List user policies and actions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

List user policies and actions

L1 Bithead

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 

1 accepted solution

Accepted Solutions

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;

View solution in original post

11 REPLIES 11

L3 Networker

Hi Sultan,

What cloud provider are you trying to pull a list of users for?

Thanks,

Eddie

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 

 

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

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;

 

 

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;

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. 

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

Thanks Eddie. That makes sense!

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.

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.

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.

  • 1 accepted solution
  • 8706 Views
  • 11 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!