Other Articles

KMS Key – Avoid Pending Deletion

Secure Configuration Checks > AWS

This check flags customer-managed AWS KMS keys that are pending deletion or pending replica deletion, so that you can review them before the deletion completes. Deleting a KMS key cannot be undone. Everything that was encrypted with the key becomes unreadable for good.

Check Details

  • Resource: KMS Key (customer-managed)
  • Check: Avoid KMS key pending deletion (NoPendingDeletion)
  • Risk: Data, backups, volumes, secrets and logs that use the key are lost for good once the deletion completes

Key states covered

  • Pending deletion (PendingDeletion): The key is scheduled for deletion. It cannot be used and is deleted when the waiting period of 7 to 30 days ends.
  • Pending replica deletion (PendingReplicaDeletion): The key is a multi-Region primary key that is scheduled for deletion, but it still has replica keys. The waiting period starts after the last replica is deleted.

Remediation via AWS Console

  1. Log in to the AWS Management Console and open the AWS Key Management Service (KMS) console.

    AWS KMS Console
  2. In the left navigation pane, click Customer managed keys. Look for keys with the status Pending deletion or Pending replica deletion.

    KMS customer managed keys pending deletion
  3. Select the key and review its details, aliases and the deletion date.
  4. Click Key actions and then Cancel key deletion. Confirm the action.
  5. The key is now Disabled. Click Key actions and then Enable if the key must be used again.
  6. Repeat steps 3 to 5 for every key that you want to keep. Leave a key as it is only if you have confirmed that it is no longer needed.

Remediation via AWS CLI

  1. Log in to the AWS Management Console and click the CloudShell icon (>_) in the top-right corner.

    AWS CloudShell
  2. List the customer-managed keys that are pending deletion. The output shows the key ID, the state, the deletion date and the description:

    for k in $(aws kms list-keys --query 'Keys[].KeyId' --output text); do
      aws kms describe-key --key-id "$k" --output json | \
      jq -r '.KeyMetadata
        | select(.KeyManager == "CUSTOMER"
            and (.KeyState == "PendingDeletion" or .KeyState == "PendingReplicaDeletion"))
        | [.KeyId, .KeyState, (.DeletionDate // "n/a"), (.Description // "")]
        | @tsv'
    done
    

    The command covers one region. Add --region <region> to each aws command to check another.

  3. Check the aliases and grants of the key to see what still depends on it:

    aws kms list-aliases --key-id <key-id>
    
    aws kms list-grants --key-id <key-id>
    
  4. Cancel the deletion of a key that you want to keep:

    aws kms cancel-key-deletion --key-id <key-id>
    

    The key is now disabled. Enable it again so that it can be used:

    aws kms enable-key --key-id <key-id>
    
  5. Verify the state of the key:

    aws kms describe-key \
    --key-id <key-id> \
    --query 'KeyMetadata.[KeyId,KeyState,Enabled]' \
    --output text
    

    The state must be Enabled, not PendingDeletion or PendingReplicaDeletion.

Replace <key-id> with the ID of the key, for example 1234abcd-12ab-34cd-56ef-1234567890ab. Repeat steps 3 to 5 for each key that you want to keep.

Updated on 04 November, 2026