AWS SDK Version 3 for .NET
API Reference

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.

Provides detailed information about a KMS key. You can run DescribeKey on a customer managed key or an Amazon Web Services managed key.

This detailed information includes the key ARN, creation date (and deletion date, if applicable), the key state, and the origin and expiration date (if any) of the key material. It includes fields, like KeySpec, that help you distinguish different types of KMS keys. It also displays the key usage (encryption, signing, or generating and verifying MACs) and the algorithms that the KMS key supports.

For multi-Region keys, DescribeKey displays the primary key and all related replica keys. For KMS keys in CloudHSM key stores, it includes information about the key store, such as the key store ID and the CloudHSM cluster ID. For KMS keys in external key stores, it includes the custom key store ID and the ID of the external key.

DescribeKey does not return the following information:

In general, DescribeKey is a non-mutating operation. It returns data about KMS keys, but doesn't change them. However, Amazon Web Services services use DescribeKey to create Amazon Web Services managed keys from a predefined Amazon Web Services alias with no key ID.

Cross-account use: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the KeyId parameter.

Required permissions: kms:DescribeKey (key policy)

Related operations:

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

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to DescribeKeyAsync.

Namespace: Amazon.KeyManagementService
Assembly: AWSSDK.KeyManagementService.dll
Version: 3.x.y.z

Syntax

C#
public virtual DescribeKeyResponse DescribeKey(
         DescribeKeyRequest request
)

Parameters

request
Type: Amazon.KeyManagementService.Model.DescribeKeyRequest

Container for the necessary parameters to execute the DescribeKey service method.

Return Value


The response from the DescribeKey service method, as returned by KeyManagementService.

Exceptions

ExceptionCondition
DependencyTimeoutException The system timed out while trying to fulfill the request. You can retry the request.
InvalidArnException The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.
KMSInternalException The request was rejected because an internal exception occurred. The request can be retried.
NotFoundException The request was rejected because the specified entity or resource could not be found.

Examples

The following example gets metadata for a symmetric encryption KMS key.

To get details about a KMS key


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

The following example gets metadata for an asymmetric RSA KMS key used for signing and verification.

To get details about an RSA asymmetric KMS key


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

The following example gets metadata for a multi-Region replica key. This multi-Region key is a symmetric encryption key. DescribeKey returns information about the primary key and all of its replicas.

To get details about a multi-Region key


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "arn:aws:kms:ap-northeast-1:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

The following example gets the metadata of an HMAC KMS key.

To get details about an HMAC KMS key


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

The following example gets the metadata of a KMS key in an AWS CloudHSM key store.

To get details about a KMS key in an AWS CloudHSM key store


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

The following example gets the metadata of a KMS key in an external key store.

To get details about a KMS key in an external key store


var client = new AmazonKeyManagementServiceClient();
var response = client.DescribeKey(new DescribeKeyRequest 
{
    KeyId = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab" // An identifier for the KMS key. You can use the key ID, key ARN, alias name, alias ARN of the KMS key.
});

KeyMetadata keyMetadata = response.KeyMetadata; // An object that contains information about the specified KMS key.

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

See Also