Back to Aws Sdk Js V3

@aws-sdk/client-resource-groups

clients/client-resource-groups/README.md

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

@aws-sdk/client-resource-groups

Description

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

<p>Resource Groups lets you organize Amazon Web Services resources such as Amazon Elastic Compute Cloud instances, Amazon Relational Database Service databases, and Amazon Simple Storage Service buckets into groups using criteria that you define as tags. A resource group is a collection of resources that match the resource types specified in a query, and share one or more tags or portions of tags. You can create a group of resources based on their roles in your cloud infrastructure, lifecycle stages, regions, application layers, or virtually any criteria. Resource Groups enable you to automate management tasks, such as those in Amazon Web Services Systems Manager Automation documents, on tag-related resources in Amazon Web Services Systems Manager. Groups of tagged resources also let you quickly view a custom console in Amazon Web Services Systems Manager that shows Config compliance and other monitoring data about member resources.</p> <p>To create a resource group, build a resource query, and specify tags that identify the criteria that members of the group have in common. Tags are key-value pairs.</p> <p>For more information about Resource Groups, see the <a href="https://docs.aws.amazon.com/ARG/latest/userguide/welcome.html">Resource Groups User Guide</a>.</p> <p>Resource Groups uses a REST-compliant API that you can use to perform the following types of operations.</p> <ul> <li> <p>Create, Read, Update, and Delete (CRUD) operations on resource groups and resource query entities</p> </li> <li> <p>Applying, editing, and removing tags from resource groups</p> </li> <li> <p>Resolving resource group member Amazon resource names (ARN)s so they can be returned as search results</p> </li> <li> <p>Getting data about resources that are members of a group</p> </li> <li> <p>Searching Amazon Web Services resources based on a resource query</p> </li> </ul>

Installing

To install this package, use the CLI of your favorite package manager:

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

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the ResourceGroupsClient and the commands you need, for example ListGroupsCommand:

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

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 ResourceGroupsClient({ 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.

ResourceGroups extends ResourceGroupsClient 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 (ResourceGroupsClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { ResourceGroups } from "@aws-sdk/client-resource-groups";

const client = new ResourceGroups({ 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-resource-groups 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> CancelTagSyncTask </summary>

Command API Reference / Input / Output

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

Command API Reference / Input / Output

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

Command API Reference / Input / Output

</details> <details> <summary> GetAccountSettings </summary>

Command API Reference / Input / Output

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

Command API Reference / Input / Output

</details> <details> <summary> GetGroupConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetGroupQuery </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetTags </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetTagSyncTask </summary>

Command API Reference / Input / Output

</details> <details> <summary> GroupResources </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroupingStatuses </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListGroupResources </summary>

Command API Reference / Input / Output

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

Command API Reference / Input / Output

</details> <details> <summary> ListTagSyncTasks </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutGroupConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> SearchResources </summary>

Command API Reference / Input / Output

</details> <details> <summary> StartTagSyncTask </summary>

Command API Reference / Input / Output

</details> <details> <summary> Tag </summary>

Command API Reference / Input / Output

</details> <details> <summary> UngroupResources </summary>

Command API Reference / Input / Output

</details> <details> <summary> Untag </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateAccountSettings </summary>

Command API Reference / Input / Output

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

Command API Reference / Input / Output

</details> <details> <summary> UpdateGroupQuery </summary>

Command API Reference / Input / Output

</details>