title: Cant remove role due to attached policy
body: <p>Im dynamically creating a role with an attached policy.  </p>
  
  <pre><code>var pr = new CreateRoleRequest
  {
    RoleName = roleName,
    AssumeRolePolicyDocument = asspoly.ToJson(),
  };
  var resp = await _iamService.CreateRoleAsync(pr);
  
  if (resp == null || resp.HttpStatusCode != HttpStatusCode.OK)
  {
    throw new Exception($"Could not create role: {resp.HttpStatusCode}");
  }
  
  var gresp = await _iamService.AttachRolePolicyAsync(new AttachRolePolicyRequest { RoleName = roleName, PolicyArn = GetPolicyARN(MakeRolePolicyName(agentID)) });
  if (gresp == null || gresp.HttpStatusCode != HttpStatusCode.OK)
  {
    throw new Exception($"Could not attach policy to role: {resp.HttpStatusCode}");
  }
  </code></pre>
  
  <p>This seems to work fine, but I also need to remove this role.  To remove the role I need to detach the policies first.</p>
  
  <pre><code>var allpolys = await _iamService.ListRolePoliciesAsync(new ListRolePoliciesRequest { RoleName = roleName, MaxItems = 10 });
  foreach (var poly in allpolys.PolicyNames)
  {
    var polyArn = GetPolicyARN(poly);
  
    var dresp = await _iamService.DetachRolePolicyAsync(new DetachRolePolicyRequest { RoleName = roleName, PolicyArn = polyArn });
    if (dresp == null || dresp.HttpStatusCode != HttpStatusCode.OK)
    {
      throw new Exception($"Could not detach role policy: {poly}");
    }
  }
  </code></pre>
  
  <p>Problem is, ListRolePolicies returns an empty list (from c# and cli) - and yet, the console shows the policy is indeed attached.</p>
  
  <p><a href="https://i.stack.imgur.com/eOxhc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eOxhc.png" alt="enter image description here"></a></p>
  
  <p>What am I missing here?</p>