ListKeys - AWS Key Management Service

ListKeys

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

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

Required permissions: kms:ListKeys (IAM policy)

Related operations:

Eventual consistency: The AWS KMS API follows an eventual consistency model. For more information, see AWS KMS eventual consistency.

Request Syntax

{ "Limit": number, "Marker": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Note

In the following list, the required parameters are described first.

Limit

Use this parameter to specify the maximum number of items to return. When this value is present, AWS KMS does not return more than the specified number of items, but it might return fewer.

This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 1000.

Required: No

Marker

Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: [\u0020-\u00FF]*

Required: No

Response Syntax

{ "Keys": [ { "KeyArn": "string", "KeyId": "string" } ], "NextMarker": "string", "Truncated": boolean }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

Keys

A list of KMS keys.

Type: Array of KeyListEntry objects

NextMarker

When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: [\u0020-\u00FF]*

Truncated

A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request.

Type: Boolean

Errors

For information about the errors that are common to all actions, see Common Errors.

DependencyTimeoutException

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

HTTP Status Code: 500

InvalidMarkerException

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

HTTP Status Code: 400

KMSInternalException

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

HTTP Status Code: 500

Examples

The following examples are formatted for legibility.

Example Request

This example illustrates one usage of ListKeys.

POST / HTTP/1.1 Host: kms.us-east-2.amazonaws.com Content-Length: 2 X-Amz-Target: TrentService.ListKeys X-Amz-Date: 20161207T003550Z Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\ Credential=AKIAI44QH8DHBEXAMPLE/20161207/us-east-2/kms/aws4_request,\ SignedHeaders=content-type;host;x-amz-date;x-amz-target,\ Signature=2196a20c1a139ae8f6fe070881f41954616c775bb5a484814c35f8ee35cfa448 {}

Example Response

This example illustrates one usage of ListKeys.

HTTP/1.1 200 OK Server: Server Date: Wed, 07 Dec 2016 00:35:50 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 980 Connection: keep-alive x-amzn-RequestId: 1a5f0a53-bc15-11e6-82b3-e9e4af764a06 { "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 }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: