clients/client-organizations/README.md
AWS SDK for JavaScript Organizations Client for Node.js, Browser and React Native.
<p>Organizations is a web service that enables you to consolidate your multiple Amazon Web Services accounts into an <i>organization</i> and centrally manage your accounts and their resources.</p> <p>This guide provides descriptions of the Organizations operations. For more information about using this service, see the <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html">Organizations User Guide</a>.</p> <p> <b>Support and feedback for Organizations</b> </p> <p>We welcome your feedback. You can post your feedback and questions in the <a href="https://forums.aws.amazon.com/forum.jspa?forumID=219">Organizations support forum</a>. For more information about the Amazon Web Services Support forums, see <a href="https://forums.aws.amazon.com/help.jspa">Forums Help</a>.</p> <p> <b>Endpoint to call When using the CLI or the Amazon Web Services SDK</b> </p> <p>For the current release of Organizations, specify the <code>us-east-1</code> region for all Amazon Web Services API and CLI calls made from the commercial Amazon Web Services Regions outside of China. If calling from one of the Amazon Web Services Regions in China, then specify <code>cn-northwest-1</code>. You can do this in the CLI by using these parameters and commands:</p> <ul> <li> <p>Use the following parameter with each command to specify both the endpoint and its region:</p> <p> <code>--endpoint-url https://organizations.us-east-1.amazonaws.com</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>--endpoint-url https://organizations.cn-northwest-1.amazonaws.com.cn</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> <li> <p>Use the default endpoint, but configure your default region with this command:</p> <p> <code>aws configure set default.region us-east-1</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>aws configure set default.region cn-northwest-1</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> <li> <p>Use the following parameter with each command to specify the endpoint:</p> <p> <code>--region us-east-1</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>--region cn-northwest-1</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> </ul> <p> <b>Recording API Requests</b> </p> <p>Organizations supports CloudTrail, a service that records Amazon Web Services API calls for your Amazon Web Services account and delivers log files to an Amazon S3 bucket. By using information collected by CloudTrail, you can determine which requests the Organizations service received, who made the request and when, and so on. For more about Organizations and its support for CloudTrail, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_incident-response.html#orgs_cloudtrail-integration">Logging Organizations API calls with CloudTrail</a> in the <i>Organizations User Guide</i>. To learn more about CloudTrail, including how to turn it on and find your log files, see the <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/what_is_cloud_trail_top_level.html">CloudTrail User Guide</a>.</p>To install this package, use the CLI of your favorite package manager:
npm install @aws-sdk/client-organizationsyarn add @aws-sdk/client-organizationspnpm add @aws-sdk/client-organizationsThe AWS SDK is modulized by clients and commands.
To send a request, you only need to import the OrganizationsClient and
the commands you need, for example ListRootsCommand:
// ES5 example
const { OrganizationsClient, ListRootsCommand } = require("@aws-sdk/client-organizations");
// ES6+ example
import { OrganizationsClient, ListRootsCommand } from "@aws-sdk/client-organizations";
To send a request:
send operation on the client, providing the command object as input.const client = new OrganizationsClient({ region: "REGION" });
const params = { /** input parameters */ };
const command = new ListRootsCommand(params);
We recommend using the 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.
}
You can also use Promise chaining.
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
The aggregated client class is exported from the same package, but without the "Client" suffix.
Organizations extends OrganizationsClient 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 (OrganizationsClient).
More details are in the blog post on
modular packages in AWS SDK for JavaScript.
import { Organizations } from "@aws-sdk/client-organizations";
const client = new Organizations({ region: "REGION" });
// async/await.
try {
const data = await client.listRoots(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listRoots(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks (not recommended).
client.listRoots(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).
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.
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.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js.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-organizations 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.
Command API Reference / Input / Output
</details> <details> <summary> AttachPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> CancelHandshake </summary>Command API Reference / Input / Output
</details> <details> <summary> CloseAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateGovCloudAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateOrganizationalUnit </summary>Command API Reference / Input / Output
</details> <details> <summary> CreatePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DeclineHandshake </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteOrganizationalUnit </summary>Command API Reference / Input / Output
</details> <details> <summary> DeletePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteResourcePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DeregisterDelegatedAdministrator </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeCreateAccountStatus </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeEffectivePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeHandshake </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeOrganizationalUnit </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeResourcePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeResponsibilityTransfer </summary>Command API Reference / Input / Output
</details> <details> <summary> DetachPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> DisableAWSServiceAccess </summary>Command API Reference / Input / Output
</details> <details> <summary> DisablePolicyType </summary>Command API Reference / Input / Output
</details> <details> <summary> EnableAllFeatures </summary>Command API Reference / Input / Output
</details> <details> <summary> EnableAWSServiceAccess </summary>Command API Reference / Input / Output
</details> <details> <summary> EnablePolicyType </summary>Command API Reference / Input / Output
</details> <details> <summary> InviteAccountToOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> InviteOrganizationToTransferResponsibility </summary>Command API Reference / Input / Output
</details> <details> <summary> LeaveOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> ListAccounts </summary>Command API Reference / Input / Output
</details> <details> <summary> ListAccountsForParent </summary>Command API Reference / Input / Output
</details> <details> <summary> ListAccountsWithInvalidEffectivePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> ListAWSServiceAccessForOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> ListChildren </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCreateAccountStatus </summary>Command API Reference / Input / Output
</details> <details> <summary> ListDelegatedAdministrators </summary>Command API Reference / Input / Output
</details> <details> <summary> ListDelegatedServicesForAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> ListEffectivePolicyValidationErrors </summary>Command API Reference / Input / Output
</details> <details> <summary> ListHandshakesForAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> ListHandshakesForOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> ListInboundResponsibilityTransfers </summary>Command API Reference / Input / Output
</details> <details> <summary> ListOrganizationalUnitsForParent </summary>Command API Reference / Input / Output
</details> <details> <summary> ListOutboundResponsibilityTransfers </summary>Command API Reference / Input / Output
</details> <details> <summary> ListParents </summary>Command API Reference / Input / Output
</details> <details> <summary> ListPolicies </summary>Command API Reference / Input / Output
</details> <details> <summary> ListPoliciesForTarget </summary>Command API Reference / Input / Output
</details> <details> <summary> ListRoots </summary>Command API Reference / Input / Output
</details> <details> <summary> ListTagsForResource </summary>Command API Reference / Input / Output
</details> <details> <summary> ListTargetsForPolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> MoveAccount </summary>Command API Reference / Input / Output
</details> <details> <summary> PutResourcePolicy </summary>Command API Reference / Input / Output
</details> <details> <summary> RegisterDelegatedAdministrator </summary>Command API Reference / Input / Output
</details> <details> <summary> RemoveAccountFromOrganization </summary>Command API Reference / Input / Output
</details> <details> <summary> TagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> TerminateResponsibilityTransfer </summary>Command API Reference / Input / Output
</details> <details> <summary> UntagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateOrganizationalUnit </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdatePolicy </summary> </details> <details> <summary> UpdateResponsibilityTransfer </summary> </details>