title: How to get the permission or group details of the users in AWS iam using boto
body: <p>I have successfully fetched the users from AWS IAM using the python boto module.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>import  boto
  from boto.iam.connection import IAMConnection
  
  
      cfn = IAMConnection(aws_access_key_id='somekeyid',aws_secret_access_key ='secret_here')
      data = cfn.get_all_users()
  
      for user in data.users:
          print user,"\n"
  </code></pre>
  
  <blockquote>
    <p>How do I get the Groups or Permissions the user is associated with?</p>
  </blockquote>
  
  <p>I added this line of code to get the group associated with the users and I am getting the error mentioned down below.</p>
  
  <p><strong>Added Code:</strong></p>
  
  <pre><code>group=cfn.get_groups_for_user("Shital")
  print group
  </code></pre>
  
  <p>where "Shital" is the user that exists and is being fetched from above. For test purposes, I am manually passing it to a function call.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "getuser.py", line 14, in &lt;module&gt;
      pol=cfn.get_groups_for_user("Shita")
    File "/home/tara/testinghere/IAM/env/local/lib/python2.7/site-packages/boto/iam/connection.py", line 509, in get_groups_for_user
      list_marker='Groups')
    File "/home/tara/testinghere/IAM/env/local/lib/python2.7/site-packages/boto/iam/connection.py", line 102, in get_response
      raise self.ResponseError(response.status, response.reason, body)
  boto.exception.BotoServerError: BotoServerError: 403 Forbidden
  &lt;ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/"&gt;
    &lt;Error&gt;
      &lt;Type&gt;Sender&lt;/Type&gt;
      &lt;Code&gt;AccessDenied&lt;/Code&gt;
      &lt;Message&gt;User: arn:aws:iam::586848946515:user/qa-api-users is not authorized to perform: iam:ListGroupsForUser on resource: user Shita&lt;/Message&gt;
    &lt;/Error&gt;
    &lt;RequestId&gt;7e9a4b56-95f0-11e7-9bb0-8b8eb22708c5&lt;/RequestId&gt;
  &lt;/ErrorResponse&gt;
  </code></pre>