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 ListKeysCommandProtected

Gets a list of all KMS keys in the caller's Amazon Web Services account and Region.

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

Required permissions: kms:ListKeys (IAM policy)

Related operations:

Example

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

import { KMSClient, ListKeysCommand } from "@aws-sdk/client-kms"; // ES Modules import
// const { KMSClient, ListKeysCommand } = require("@aws-sdk/client-kms"); // CommonJS import
const client = new KMSClient(config);
const input = { // ListKeysRequest
Limit: Number("int"),
Marker: "STRING_VALUE",
};
const command = new ListKeysCommand(input);
const response = await client.send(command);
// { // ListKeysResponse
// Keys: [ // KeyList
// { // KeyListEntry
// KeyId: "STRING_VALUE",
// KeyArn: "STRING_VALUE",
// },
// ],
// NextMarker: "STRING_VALUE",
// Truncated: true || false,
// };

Param

ListKeysCommandInput

Returns

ListKeysCommandOutput

See

Throws

DependencyTimeoutException (server fault)

The system timed out while trying to fulfill the request. You can retry the request.

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

KMSServiceException

Base exception class for all service exceptions from KMS service.

Example

To list KMS keys

// The following example lists KMS keys.
const input = undefined;
const command = new ListKeysCommand(input);
const response = await client.send(command);
/* response ==
{
"Keys": [
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/0d990263-018e-4e65-a703-eff731de951e",
"KeyId": "0d990263-018e-4e65-a703-eff731de951e"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/144be297-0ae1-44ac-9c8f-93cd8c82f841",
"KeyId": "144be297-0ae1-44ac-9c8f-93cd8c82f841"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/21184251-b765-428e-b852-2c7353e72571",
"KeyId": "21184251-b765-428e-b852-2c7353e72571"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/214fe92f-5b03-4ae1-b350-db2a45dbe10c",
"KeyId": "214fe92f-5b03-4ae1-b350-db2a45dbe10c"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/339963f2-e523-49d3-af24-a0fe752aa458",
"KeyId": "339963f2-e523-49d3-af24-a0fe752aa458"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/b776a44b-df37-4438-9be4-a27494e4271a",
"KeyId": "b776a44b-df37-4438-9be4-a27494e4271a"
},
{
"KeyArn": "arn:aws:kms:us-east-2:111122223333:key/deaf6c9e-cf2c-46a6-bf6d-0b6d487cffbb",
"KeyId": "deaf6c9e-cf2c-46a6-bf6d-0b6d487cffbb"
}
],
"Truncated": false
}
*/
// example id: to-list-cmks-1481071643069

Hierarchy

Constructors

Properties

middlewareStack: MiddlewareStack<ListKeysCommandInput, ListKeysCommandOutput>

Methods