Back to Aws Sdk Js V3

@aws-sdk/client-iam

clients/client-iam/README.md

3.1044.089.7 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-iam

Description

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

<fullname>Identity and Access Management</fullname>

<p>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 <a href="http://aws.amazon.com/iam/">Identity and Access Management (IAM)</a> and the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/">Identity and Access Management User Guide</a>.</p> <p> <b>Programmatic access to IAM</b> </p> <p>We recommend that you use the Amazon Web Services SDKs to make programmatic API calls to IAM. The Amazon Web Services SDKs consist of libraries and sample code for various programming languages and platforms (for example, Java, Ruby, .NET, iOS, and Android). The SDKs provide a convenient way to create programmatic access to IAM and Amazon Web Services. For example, the SDKs take care of tasks such as cryptographically signing requests, managing errors, and retrying requests automatically. For more information, see <a href="http://aws.amazon.com/tools/">Tools to build on Amazon Web Services</a>.</p> <p>Alternatively, you can also use the IAM Query API to make direct calls to the IAM service. For more information about calling the IAM Query API, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html">Making query requests</a> in the <i>Identity and Access Management User Guide</i>. IAM supports GET and POST requests for all actions. That is, the API does not require you to use GET for some actions and POST for others. However, GET requests are subject to the limitation size of a URL. Therefore, for operations that require larger sizes, use a POST request.</p> <p> <b>Signing requests</b> </p> <p>Requests must be signed using an access key ID and a secret access key. We strongly recommend that you do not use your Amazon Web Services account access key ID and secret access key for everyday work with IAM. You can use the access key ID and secret access key for an IAM user or you can use the Security Token Service to generate temporary security credentials and use those to sign requests.</p> <p>To sign requests, we recommend that you use <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Signature Version 4</a>. If you have an existing application that uses Signature Version 2, you do not have to update it to use Signature Version 4. However, some operations now require Signature Version 4. The documentation for operations that require version 4 indicate this requirement.</p> <p> <b>Additional resources</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html">Amazon Web Services security credentials</a>. This topic provides general information about the types of credentials used for accessing Amazon Web Services.</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.html">IAM best practices</a>. This topic presents a list of suggestions for using the IAM service to help secure your Amazon Web Services resources.</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html">Signing Amazon Web Services API requests</a>. This set of topics walk you through the process of signing a request using an access key ID and secret access key.</p> </li> </ul>

Installing

To install this package, use the CLI of 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:

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

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new IAMClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new ListGroupsCommand(params);

Async/await

We recommend using the 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.
}

Promises

You can also use Promise chaining.

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

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

IAM extends IAMClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (IAMClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { IAM } from "@aws-sdk/client-iam";

const client = new 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 (not recommended).
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).

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

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use 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)

<details> <summary> AcceptDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> AddClientIDToOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> AddRoleToInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> AddUserToGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> AssociateDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> AttachGroupPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> AttachRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> AttachUserPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> ChangePassword </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateAccessKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateAccountAlias </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateLoginProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreatePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreatePolicyVersion </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateServiceLinkedRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateServiceSpecificCredential </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateVirtualMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeactivateMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteAccessKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteAccountAlias </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteAccountPasswordPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteGroupPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteLoginProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeletePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeletePolicyVersion </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteRolePermissionsBoundary </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteServiceLinkedRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteServiceSpecificCredential </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteSigningCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteSSHPublicKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPermissionsBoundary </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteUserPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteVirtualMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> DetachGroupPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DetachRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DetachUserPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisableOrganizationsRootCredentialsManagement </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisableOrganizationsRootSessions </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisableOutboundWebIdentityFederation </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableOrganizationsRootCredentialsManagement </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableOrganizationsRootSessions </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableOutboundWebIdentityFederation </summary>

Command API Reference / Input / Output

</details> <details> <summary> GenerateCredentialReport </summary>

Command API Reference / Input / Output

</details> <details> <summary> GenerateOrganizationsAccessReport </summary>

Command API Reference / Input / Output

</details> <details> <summary> GenerateServiceLastAccessedDetails </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetAccessKeyLastUsed </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetAccountAuthorizationDetails </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetAccountPasswordPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetAccountSummary </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetContextKeysForCustomPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetContextKeysForPrincipalPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetCredentialReport </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetGroupPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetHumanReadableSummary </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetLoginProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetOrganizationsAccessReport </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetOutboundWebIdentityFederationInfo </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetPolicyVersion </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetServiceLastAccessedDetails </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetServiceLastAccessedDetailsWithEntities </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetServiceLinkedRoleDeletionStatus </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetSSHPublicKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetUserPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAccessKeys </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAccountAliases </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAttachedGroupPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAttachedRolePolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAttachedUserPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListDelegationRequests </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListEntitiesForPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroupPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroups </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroupsForUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListInstanceProfiles </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListInstanceProfilesForRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListInstanceProfileTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListMFADevices </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListMFADeviceTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListOpenIDConnectProviders </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListOpenIDConnectProviderTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListOrganizationsFeatures </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPoliciesGrantingServiceAccess </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPolicyTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPolicyVersions </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListRolePolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListRoles </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListRoleTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListSAMLProviders </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListSAMLProviderTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListServerCertificates </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListServerCertificateTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListServiceSpecificCredentials </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListSigningCertificates </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListSSHPublicKeys </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUsers </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListUserTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListVirtualMFADevices </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutGroupPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutRolePermissionsBoundary </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutUserPermissionsBoundary </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutUserPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> RejectDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> RemoveClientIDFromOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> RemoveRoleFromInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> RemoveUserFromGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> ResetServiceSpecificCredential </summary>

Command API Reference / Input / Output

</details> <details> <summary> ResyncMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> SendDelegationToken </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetDefaultPolicyVersion </summary>

Command API Reference / Input / Output

</details> <details> <summary> SetSecurityTokenServicePreferences </summary>

Command API Reference / Input / Output

</details> <details> <summary> SimulateCustomPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> SimulatePrincipalPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagInstanceProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagMFADevice </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagOpenIDConnectProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateAccessKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateAccountPasswordPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateAssumeRolePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateDelegationRequest </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateGroup </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateLoginProfile </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateOpenIDConnectProviderThumbprint </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateRole </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateRoleDescription </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateSAMLProvider </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateServiceSpecificCredential </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateSigningCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateSSHPublicKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateUser </summary>

Command API Reference / Input / Output

</details> <details> <summary> UploadServerCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> UploadSigningCertificate </summary>

Command API Reference / Input / Output

</details> <details> <summary> UploadSSHPublicKey </summary>

Command API Reference / Input / Output

</details>