AWS SDK for JavaScript Iam Client for Node.js, Browser and React Native
npm install @aws-sdk/client-iamAWS SDK for JavaScript IAM Client for Node.js, Browser and React Native.
Identity and Access Management (IAM) is a web service for securely controlling
access to Amazon Web Services services. With IAM, you can centrally manage users, security credentials
such as access keys, and permissions that control which Amazon Web Services resources users and
applications can access. For more information about IAM, see Identity and Access Management (IAM) and the Identity and Access Management User Guide.
npm install @aws-sdk/client-iamyarn add @aws-sdk/client-iampnpm add @aws-sdk/client-iamThe AWS SDK is modulized by clients and commands.
To send a request, you only need to import the IAMClient and
the commands you need, for example ListGroupsCommand:
``js`
// ES5 example
const { IAMClient, ListGroupsCommand } = require("@aws-sdk/client-iam");
`ts`
// ES6+ example
import { IAMClient, ListGroupsCommand } from "@aws-sdk/client-iam";
To send a request, you:
- Initiate client with configuration (e.g. credentials, region).
- Initiate command with input parameters.
- Call send operation on client with command object as input.destroy()
- If you are using a custom http handler, you may call to close open connections.
`js
// a client can be shared by different commands.
const client = new IAMClient({ region: "REGION" });
const params = { /* input parameters / };
const command = new ListGroupsCommand(params);
`
#### Async/await
We recommend using await
operator to wait for the promise returned by send operation as follows:
`js`
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling
as compared to using Promise chains or callbacks.
#### Promises
You can also use Promise chaining
to execute send operation.
`js`
client.send(command).then(
(data) => {
// process data.
},
(error) => {
// error handling.
}
);
Promises can also be called using .catch() and .finally() as follows:
`js`
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
#### Callbacks
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
`js`
// callbacks.
client.send(command, (err, data) => {
// process err and data.
});
#### v2 compatible style
The client can also send requests using v2 compatible style.
However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post
on modular packages in AWS SDK for JavaScript
`ts
import * as AWS from "@aws-sdk/client-iam";
const client = new AWS.IAM({ region: "REGION" });
// async/await.
try {
const data = await client.listGroups(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listGroups(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks.
client.listGroups(params, (err, data) => {
// process err and data.
});
`
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
`js`
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
Please use these community resources for getting help.
We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
- Visit Developer Guide
or API Reference.
- Check out the blog posts tagged with aws-sdk-js
on AWS Developer Blog.
- Ask a question on StackOverflow and tag it with aws-sdk-js.
- Join the AWS JavaScript community on gitter.
- If it turns out that you may have found a bug, please open an issue.
To test your universal JavaScript code in Node.js, browser and react-native environments,
visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-iam` package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE for more information.
AcceptDelegationRequest
Command API Reference / Input / Output
AddClientIDToOpenIDConnectProvider
Command API Reference / Input / Output
AddRoleToInstanceProfile
Command API Reference / Input / Output
AddUserToGroup
Command API Reference / Input / Output
AssociateDelegationRequest
Command API Reference / Input / Output
AttachGroupPolicy
Command API Reference / Input / Output
AttachRolePolicy
Command API Reference / Input / Output
AttachUserPolicy
Command API Reference / Input / Output
ChangePassword
Command API Reference / Input / Output
CreateAccessKey
Command API Reference / Input / Output
CreateAccountAlias
Command API Reference / Input / Output
CreateDelegationRequest
Command API Reference / Input / Output
CreateGroup
Command API Reference / Input / Output
CreateInstanceProfile
Command API Reference / Input / Output
CreateLoginProfile
Command API Reference / Input / Output
CreateOpenIDConnectProvider
Command API Reference / Input / Output
CreatePolicy
Command API Reference / Input / Output
CreatePolicyVersion
Command API Reference / Input / Output
CreateRole
Command API Reference / Input / Output
CreateSAMLProvider
Command API Reference / Input / Output
CreateServiceLinkedRole
Command API Reference / Input / Output
CreateServiceSpecificCredential
Command API Reference / Input / Output
CreateUser
Command API Reference / Input / Output
CreateVirtualMFADevice
Command API Reference / Input / Output
DeactivateMFADevice
Command API Reference / Input / Output
DeleteAccessKey
Command API Reference / Input / Output
DeleteAccountAlias
Command API Reference / Input / Output
DeleteAccountPasswordPolicy
Command API Reference / Input / Output
DeleteGroup
Command API Reference / Input / Output
DeleteGroupPolicy
Command API Reference / Input / Output
DeleteInstanceProfile
Command API Reference / Input / Output
DeleteLoginProfile
Command API Reference / Input / Output
DeleteOpenIDConnectProvider
Command API Reference / Input / Output
DeletePolicy
Command API Reference / Input / Output
DeletePolicyVersion
Command API Reference / Input / Output
DeleteRole
Command API Reference / Input / Output
DeleteRolePermissionsBoundary
Command API Reference / Input / Output
DeleteRolePolicy
Command API Reference / Input / Output
DeleteSAMLProvider
Command API Reference / Input / Output
DeleteServerCertificate
Command API Reference / Input / Output
DeleteServiceLinkedRole
Command API Reference / Input / Output
DeleteServiceSpecificCredential
Command API Reference / Input / Output
DeleteSigningCertificate
Command API Reference / Input / Output
DeleteSSHPublicKey
Command API Reference / Input / Output
DeleteUser
Command API Reference / Input / Output
DeleteUserPermissionsBoundary
Command API Reference / Input / Output
DeleteUserPolicy
Command API Reference / Input / Output
DeleteVirtualMFADevice
Command API Reference / Input / Output
DetachGroupPolicy
Command API Reference / Input / Output
DetachRolePolicy
Command API Reference / Input / Output
DetachUserPolicy
Command API Reference / Input / Output
DisableOrganizationsRootCredentialsManagement
Command API Reference / Input / Output
DisableOrganizationsRootSessions
Command API Reference / Input / Output
DisableOutboundWebIdentityFederation
Command API Reference / Input / Output
EnableMFADevice
Command API Reference / Input / Output
EnableOrganizationsRootCredentialsManagement
Command API Reference / Input / Output
EnableOrganizationsRootSessions
Command API Reference / Input / Output
EnableOutboundWebIdentityFederation
Command API Reference / Input / Output
GenerateCredentialReport
Command API Reference / Input / Output
GenerateOrganizationsAccessReport
Command API Reference / Input / Output
GenerateServiceLastAccessedDetails
Command API Reference / Input / Output
GetAccessKeyLastUsed
Command API Reference / Input / Output
GetAccountAuthorizationDetails
Command API Reference / Input / Output
GetAccountPasswordPolicy
Command API Reference / Input / Output
GetAccountSummary
Command API Reference / Input / Output
GetContextKeysForCustomPolicy
Command API Reference / Input / Output
GetContextKeysForPrincipalPolicy
Command API Reference / Input / Output
GetCredentialReport
Command API Reference / Input / Output
GetDelegationRequest
Command API Reference / Input / Output
GetGroup
Command API Reference / Input / Output
GetGroupPolicy
Command API Reference / Input / Output
GetHumanReadableSummary
Command API Reference / Input / Output
GetInstanceProfile
Command API Reference / Input / Output
GetLoginProfile
Command API Reference / Input / Output
GetMFADevice
Command API Reference / Input / Output
GetOpenIDConnectProvider
Command API Reference / Input / Output
GetOrganizationsAccessReport
Command API Reference / Input / Output
GetOutboundWebIdentityFederationInfo
Command API Reference / Input / Output
GetPolicy
Command API Reference / Input / Output
GetPolicyVersion
Command API Reference / Input / Output
GetRole
Command API Reference / Input / Output
GetRolePolicy
Command API Reference / Input / Output
GetSAMLProvider
Command API Reference / Input / Output
GetServerCertificate
Command API Reference / Input / Output
GetServiceLastAccessedDetails
Command API Reference / Input / Output
GetServiceLastAccessedDetailsWithEntities
Command API Reference / Input / Output
GetServiceLinkedRoleDeletionStatus
Command API Reference / Input / Output
GetSSHPublicKey
Command API Reference / Input / Output
GetUser
Command API Reference / Input / Output
GetUserPolicy
Command API Reference / Input / Output
ListAccessKeys
Command API Reference / Input / Output
ListAccountAliases
Command API Reference / Input / Output
ListAttachedGroupPolicies
Command API Reference / Input / Output
ListAttachedRolePolicies
Command API Reference / Input / Output
ListAttachedUserPolicies
Command API Reference / Input / Output
ListDelegationRequests
Command API Reference / Input / Output
ListEntitiesForPolicy
Command API Reference / Input / Output
ListGroupPolicies
Command API Reference / Input / Output
ListGroups
Command API Reference / Input / Output
ListGroupsForUser
Command API Reference / Input / Output
ListInstanceProfiles
Command API Reference / Input / Output
ListInstanceProfilesForRole
Command API Reference / Input / Output
ListInstanceProfileTags
Command API Reference / Input / Output
ListMFADevices
Command API Reference / Input / Output
ListMFADeviceTags
Command API Reference / Input / Output
ListOpenIDConnectProviders
Command API Reference / Input / Output
ListOpenIDConnectProviderTags
Command API Reference / Input / Output
ListOrganizationsFeatures
Command API Reference / Input / Output
ListPolicies
Command API Reference / Input / Output
ListPoliciesGrantingServiceAccess
Command API Reference / Input / Output
ListPolicyTags
Command API Reference / Input / Output
ListPolicyVersions
Command API Reference / Input / Output
ListRolePolicies
Command API Reference / Input / Output
ListRoles
Command API Reference / Input / Output
ListRoleTags
Command API Reference / Input / Output
ListSAMLProviders
Command API Reference / Input / Output
ListSAMLProviderTags
Command API Reference / Input / Output
ListServerCertificates
Command API Reference / Input / Output
ListServerCertificateTags
Command API Reference / Input / Output
ListServiceSpecificCredentials
Command API Reference / Input / Output
ListSigningCertificates
Command API Reference / Input / Output
ListSSHPublicKeys
Command API Reference / Input / Output
ListUserPolicies
Command API Reference / Input / Output
ListUsers
Command API Reference / Input / Output
ListUserTags
Command API Reference / Input / Output
ListVirtualMFADevices
Command API Reference / Input / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/la