TagResourceCommand

Associates tags with an OpenSearch Serverless resource. For more information, see Tagging Amazon OpenSearch Serverless collections .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { OpenSearchServerlessClient, TagResourceCommand } from "@aws-sdk/client-opensearchserverless"; // ES Modules import
// const { OpenSearchServerlessClient, TagResourceCommand } = require("@aws-sdk/client-opensearchserverless"); // CommonJS import
const client = new OpenSearchServerlessClient(config);
const input = { // TagResourceRequest
  resourceArn: "STRING_VALUE", // required
  tags: [ // Tags // required
    { // Tag
      key: "STRING_VALUE", // required
      value: "STRING_VALUE", // required
    },
  ],
};
const command = new TagResourceCommand(input);
const response = await client.send(command);
// {};

TagResourceCommand Input

See TagResourceCommandInput for more details

Parameter
Type
Description
resourceArn
Required
string | undefined

The Amazon Resource Name (ARN) of the resource. The resource must be active (not in the DELETING state), and must be owned by the account ID included in the request.

tags
Required
Tag[] | undefined

A list of tags (key-value pairs) to add to the resource. All tag keys in the request must be unique.

TagResourceCommand Output

See TagResourceCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
ConflictException
client

When creating a resource, thrown when a resource with the same name already exists or is being created. When deleting a resource, thrown when the resource is not in the ACTIVE or FAILED state.

InternalServerException
server

Thrown when an error internal to the service occurs while processing a request.

ResourceNotFoundException
client

Thrown when accessing or deleting a resource that does not exist.

ServiceQuotaExceededException
client

Thrown when you attempt to create more resources than the service allows based on service quotas.

ValidationException
client

Thrown when the HTTP request contains invalid input or is missing required input.

OpenSearchServerlessServiceException
Base exception class for all service exceptions from OpenSearchServerless service.