@aws-sdk/client-iam
TypeScript icon, indicating that this package has built-in type declarations

3.556.0 • Public • Published

@aws-sdk/client-iam

Description

AWS SDK for JavaScript IAM Client for Node.js, Browser and React Native.

Identity and Access Management

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.

Installing

To install the this package, simply type add or install @aws-sdk/client-iam using your favorite package manager:

  • npm install @aws-sdk/client-iam
  • yarn add @aws-sdk/client-iam
  • pnpm add @aws-sdk/client-iam

Getting Started

Import

The 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:

// ES5 example
const { IAMClient, ListGroupsCommand } = require("@aws-sdk/client-iam");
// ES6+ example
import { IAMClient, ListGroupsCommand } from "@aws-sdk/client-iam";

Usage

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.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// 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:

// 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.

client.send(command).then(
  (data) => {
    // process data.
  },
  (error) => {
    // error handling.
  }
);

Promises can also be called using .catch() and .finally() as follows:

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.

// 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

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.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

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;
   * }
   */
}

Getting Help

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.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

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.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

AddClientIDToOpenIDConnectProvider

Command API Reference / Input / Output

AddRoleToInstanceProfile

Command API Reference / Input / Output

AddUserToGroup

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

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

EnableMFADevice

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

GetGroup

Command API Reference / Input / Output

GetGroupPolicy

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

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

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

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

PutGroupPolicy

Command API Reference / Input / Output

PutRolePermissionsBoundary

Command API Reference / Input / Output

PutRolePolicy

Command API Reference / Input / Output

PutUserPermissionsBoundary

Command API Reference / Input / Output

PutUserPolicy

Command API Reference / Input / Output

RemoveClientIDFromOpenIDConnectProvider

Command API Reference / Input / Output

RemoveRoleFromInstanceProfile

Command API Reference / Input / Output

RemoveUserFromGroup

Command API Reference / Input / Output

ResetServiceSpecificCredential

Command API Reference / Input / Output

ResyncMFADevice

Command API Reference / Input / Output

SetDefaultPolicyVersion

Command API Reference / Input / Output

SetSecurityTokenServicePreferences

Command API Reference / Input / Output

SimulateCustomPolicy

Command API Reference / Input / Output

SimulatePrincipalPolicy

Command API Reference / Input / Output

TagInstanceProfile

Command API Reference / Input / Output

TagMFADevice

Command API Reference / Input / Output

TagOpenIDConnectProvider

Command API Reference / Input / Output

TagPolicy

Command API Reference / Input / Output

TagRole

Command API Reference / Input / Output

TagSAMLProvider

Command API Reference / Input / Output

TagServerCertificate

Command API Reference / Input / Output

TagUser

Command API Reference / Input / Output

UntagInstanceProfile

Command API Reference / Input / Output

UntagMFADevice

Command API Reference / Input / Output

UntagOpenIDConnectProvider

Command API Reference / Input / Output

UntagPolicy

Command API Reference / Input / Output

UntagRole

Command API Reference / Input / Output

UntagSAMLProvider

Command API Reference / Input / Output

UntagServerCertificate

Command API Reference / Input / Output

UntagUser

Command API Reference / Input / Output

UpdateAccessKey

Command API Reference / Input / Output

UpdateAccountPasswordPolicy

Command API Reference / Input / Output

UpdateAssumeRolePolicy

Command API Reference / Input / Output

UpdateGroup

Command API Reference / Input / Output

UpdateLoginProfile

Command API Reference / Input / Output

UpdateOpenIDConnectProviderThumbprint

Command API Reference / Input / Output

UpdateRole

Command API Reference / Input / Output

UpdateRoleDescription

Command API Reference / Input / Output

UpdateSAMLProvider

Command API Reference / Input / Output

UpdateServerCertificate

Command API Reference / Input / Output

UpdateServiceSpecificCredential

Command API Reference / Input / Output

UpdateSigningCertificate

Command API Reference / Input / Output

UpdateSSHPublicKey

Command API Reference / Input / Output

UpdateUser

Command API Reference / Input / Output

UploadServerCertificate

Command API Reference / Input / Output

UploadSigningCertificate

Command API Reference / Input / Output

UploadSSHPublicKey

Command API Reference / Input / Output

Readme

Keywords

none

Package Sidebar

Install

npm i @aws-sdk/client-iam

Weekly Downloads

1,213,694

Version

3.556.0

License

Apache-2.0

Unpacked Size

3.13 MB

Total Files

671

Last publish

Collaborators

  • mattsb42-aws
  • kuhe
  • amzn-oss
  • aws-sdk-bot
  • trivikr-aws