AWS Key Management Service

2026/04/27 - AWS Key Management Service - 1 new api methods

Changes  KMS GetKeyLastUsage API provides information on the last successful cryptographic operation performed on KMS keys. This new API provides KMS customers with the last timestamp, CloudTrail eventId, and the cryptographic operation that was performed on the key.

GetKeyLastUsage (new) Link ΒΆ

Returns usage information about the last successful cryptographic operation performed with a specified KMS key, including the operation type, timestamp, and associated CloudTrail event ID.

The TrackingStartDate in the GetKeyLastUsage response indicates the date from which KMS began recording cryptographic activity for a given key. Use this value together with KeyCreationDate to understand the key's usage history:

  • If the KeyLastUsage response element is present, the key has been used for a successful cryptographic operation since the TrackingStartDate. The response includes the operation type, timestamp, and associated CloudTrail event ID.

  • If the KeyLastUsage response element is empty and KeyCreationDate is on or after TrackingStartDate, the key has not been used for a successful cryptographic operation since it was created.

  • If the KeyLastUsage response element is empty and KeyCreationDate is before TrackingStartDate, there is no record of the key being used for a successful cryptographic operation since the TrackingStartDate. However, the key may have been used before tracking began. To determine whether the key was used before the TrackingStartDate, examine your past CloudTrail logs.

For multi-Region KMS keys, primary and replica keys track last usage independently. Each key in a multi-Region key set maintains its own usage information.

The ReEncrypt operation uses two keys: a source key for decryption and a destination key for encryption. Usage information is recorded for both keys independently, each with the CloudTrail event ID from the respective key owner's account.

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

Required permissions: kms:GetKeyLastUsage (key policy)

Related operations:

  • DescribeKey

  • DisableKey

  • ScheduleKeyDeletion

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

See also: AWS API Documentation

Request Syntax

client.get_key_last_usage(
    KeyId='string'
)
type KeyId:

string

param KeyId:

[REQUIRED]

Identifies the KMS key to get usage information for. To specify a KMS key, use its key ID or key ARN. Alias names are not supported.

Specify the key ID or key ARN of the KMS key.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

rtype:

dict

returns:

Response Syntax

{
    'KeyId': 'string',
    'KeyLastUsage': {
        'Operation': 'Decrypt'|'DeriveSharedSecret'|'Encrypt'|'GenerateDataKey'|'GenerateDataKeyPair'|'GenerateDataKeyPairWithoutPlaintext'|'GenerateDataKeyWithoutPlaintext'|'GenerateMac'|'ReEncrypt'|'Sign'|'Verify'|'VerifyMac',
        'Timestamp': datetime(2015, 1, 1),
        'CloudTrailEventId': 'string',
        'KmsRequestId': 'string'
    },
    'TrackingStartDate': datetime(2015, 1, 1),
    'KeyCreationDate': datetime(2015, 1, 1)
}

Response Structure

  • (dict) --

    • KeyId (string) --

      The globally unique identifier for the KMS key.

    • KeyLastUsage (dict) --

      Contains usage information about the last time the KMS key was used for a successful cryptographic operation. If the key has not been used since tracking began, this response element is empty.

      • Operation (string) --

        The last successful cryptographic operation the KMS key was used for. Absent if the key has not been used since KMS began tracking.

      • Timestamp (datetime) --

        The date and time when the KMS key was most recently used for a successful cryptographic operation. Absent if the key has not been used since KMS began tracking.

      • CloudTrailEventId (string) --

        The CloudTrail eventId associated with the last successful cryptographic operation. Absent if the key has not been used since KMS began tracking.

      • KmsRequestId (string) --

        The KMS request ID associated with the last successful cryptographic operation. Absent if the key has not been used since KMS began tracking.

    • TrackingStartDate (datetime) --

      The date from which KMS began recording cryptographic activity for this key, or the date the KMS key was created, whichever is later.

    • KeyCreationDate (datetime) --

      The date and time when the KMS key was created.