Jump to Content

This API Documentation is now deprecated

We are excited to announce our new API Documentation.

Class ListGroupsForUserCommandProtected

Lists the IAM groups that the specified IAM user belongs to.

You can paginate the results using the MaxItems and Marker parameters.

Example

Use a bare-bones client and the command you need to make an API call.

import { IAMClient, ListGroupsForUserCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, ListGroupsForUserCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = { // ListGroupsForUserRequest
UserName: "STRING_VALUE", // required
Marker: "STRING_VALUE",
MaxItems: Number("int"),
};
const command = new ListGroupsForUserCommand(input);
const response = await client.send(command);
// { // ListGroupsForUserResponse
// Groups: [ // groupListType // required
// { // Group
// Path: "STRING_VALUE", // required
// GroupName: "STRING_VALUE", // required
// GroupId: "STRING_VALUE", // required
// Arn: "STRING_VALUE", // required
// CreateDate: new Date("TIMESTAMP"), // required
// },
// ],
// IsTruncated: true || false,
// Marker: "STRING_VALUE",
// };

Param

ListGroupsForUserCommandInput

Returns

ListGroupsForUserCommandOutput

See

Throws

NoSuchEntityException (client fault)

The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.

Throws

ServiceFailureException (server fault)

The request processing has failed because of an unknown error, exception or failure.

Throws

IAMServiceException

Base exception class for all service exceptions from IAM service.

Example

To list the groups that an IAM user belongs to

// The following command displays the groups that the IAM user named Bob belongs to.
const input = {
"UserName": "Bob"
};
const command = new ListGroupsForUserCommand(input);
const response = await client.send(command);
/* response ==
{
"Groups": [
{
"Arn": "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/engineering/Test",
"CreateDate": "2016-11-30T14:10:01.156Z",
"GroupId": "AGP2111111111EXAMPLE",
"GroupName": "Test",
"Path": "/division_abc/subdivision_xyz/product_1234/engineering/"
},
{
"Arn": "arn:aws:iam::123456789012:group/division_abc/subdivision_xyz/product_1234/Managers",
"CreateDate": "2016-06-12T20:14:52.032Z",
"GroupId": "AGPI222222222SEXAMPLE",
"GroupName": "Managers",
"Path": "/division_abc/subdivision_xyz/product_1234/"
}
]
}
*/
// example id: 278ec2ee-fc28-4136-83fb-433af0ae46a2

Hierarchy

Constructors

Properties

Methods

Constructors

Properties

Methods