AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
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:
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
For .NET Core this operation is only available in asynchronous form. Please refer to ListKeysAsync.
Namespace: Amazon.KeyManagementService
Assembly: AWSSDK.KeyManagementService.dll
Version: 3.x.y.z
public virtual ListKeysResponse ListKeys( ListKeysRequest request )
Container for the necessary parameters to execute the ListKeys service method.
Exception | Condition |
---|---|
DependencyTimeoutException | The system timed out while trying to fulfill the request. You can retry the request. |
InvalidMarkerException | The request was rejected because the marker that specifies where pagination should next begin is not valid. |
KMSInternalException | The request was rejected because an internal exception occurred. The request can be retried. |
The following example lists KMS keys.
var client = new AmazonKeyManagementServiceClient(); var response = client.ListKeys(new ListKeysRequest { }); List<KeyListEntry> keys = response.Keys; // A list of KMS keys, including the key ID and Amazon Resource Name (ARN) of each one. bool truncated = response.Truncated; // A boolean that indicates whether there are more items in the list. Returns true when there are more items, or false when there are not.
.NET Framework:
Supported in: 4.5 and newer, 3.5