Jump to Content

New API Documentation - Developer Preview Available

We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.

Class ListResourceTagsCommandProtected

Returns all tags on the specified KMS key.

For general information about tags, including the format and syntax, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference. For information about using tags in KMS, see Tagging keys.

Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.

Required permissions: kms:ListResourceTags (key policy)

Related operations:

Example

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

import { KMSClient, ListResourceTagsCommand } from "@aws-sdk/client-kms"; // ES Modules import
// const { KMSClient, ListResourceTagsCommand } = require("@aws-sdk/client-kms"); // CommonJS import
const client = new KMSClient(config);
const input = { // ListResourceTagsRequest
KeyId: "STRING_VALUE", // required
Limit: Number("int"),
Marker: "STRING_VALUE",
};
const command = new ListResourceTagsCommand(input);
const response = await client.send(command);
// { // ListResourceTagsResponse
// Tags: [ // TagList
// { // Tag
// TagKey: "STRING_VALUE", // required
// TagValue: "STRING_VALUE", // required
// },
// ],
// NextMarker: "STRING_VALUE",
// Truncated: true || false,
// };

Param

ListResourceTagsCommandInput

Returns

ListResourceTagsCommandOutput

See

Throws

InvalidArnException (client fault)

The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.

Throws

InvalidMarkerException (client fault)

The request was rejected because the marker that specifies where pagination should next begin is not valid.

Throws

KMSInternalException (server fault)

The request was rejected because an internal exception occurred. The request can be retried.

Throws

NotFoundException (client fault)

The request was rejected because the specified entity or resource could not be found.

Throws

KMSServiceException

Base exception class for all service exceptions from KMS service.

Example

To list tags for a KMS key

// The following example lists tags for a KMS key.
const input = {
"KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab"
};
const command = new ListResourceTagsCommand(input);
const response = await client.send(command);
/* response ==
{
"Tags": [
{
"TagKey": "CostCenter",
"TagValue": "87654"
},
{
"TagKey": "CreatedBy",
"TagValue": "ExampleUser"
},
{
"TagKey": "Purpose",
"TagValue": "Test"
}
],
"Truncated": false
}
*/
// example id: to-list-tags-for-a-cmk-1483996855796

Hierarchy

Constructors

Properties

Methods