# KMSInvalidStateException: key is pending deletion

AWS error fixes · Updated 17 November 2026

**Short answer:** Someone scheduled the KMS key for deletion, and a key in the PendingDeletion state can't be used for any cryptographic operation, so every decrypt or encrypt with it fails. During the waiting period (7 to 30 days, 30 by default) you can undo it: run aws kms cancel-key-deletion, then aws kms enable-key, because a cancelled key comes back disabled. Once the waiting period ends the key and all data encrypted only under it are unrecoverable.

## What it looks like

```
An error occurred (KMSInvalidStateException) when calling the Decrypt operation:
arn:aws:kms:eu-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab is pending deletion.
```

Services surface it in their own words: S3 GETs on SSE-KMS objects fail, EBS volumes can't attach or instances fail to start, RDS and Secrets Manager can't decrypt, Lambda can't decrypt environment variables (`KMSInvalidStateException` in the function error). If the message says `is disabled` instead, the key was disabled rather than scheduled for deletion; `enable-key` alone fixes that.

## Cancel the deletion

```
KEY=arn:aws:kms:eu-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab

aws kms describe-key --key-id $KEY \
  --query 'KeyMetadata.{state:KeyState,deletionDate:DeletionDate,manager:KeyManager}'

aws kms cancel-key-deletion --key-id $KEY
aws kms enable-key --key-id $KEY
```

In the console: **KMS > Customer managed keys**, select the key, **Key actions > Cancel key deletion**, then **Key actions > Enable**. Forgetting the enable step is common: after cancelling, the key's state is `Disabled` and the errors continue with a different message.

## Find who scheduled it and what uses it

- **Who**: look up `ScheduleKeyDeletion` in CloudTrail (see [find who deleted an AWS resource](https://cloudconsole.dev/how-to/find-who-deleted-aws-resource)). Often it's a stack teardown: deleting a CloudFormation stack schedules deletion of keys it created, unless they have `DeletionPolicy: Retain`.
- **What depends on it**: CloudTrail `Decrypt`/`GenerateDataKey` events with this key ID over recent weeks show the callers. Usage during the waiting period is recorded with an error, which is why AWS suggests a CloudWatch alarm on attempts to use a key pending deletion.
- **Aliases**: an alias such as `alias/app-data` keeps pointing at the pending key; repoint it only if you intend to switch keys.

## Before deleting a key on purpose

- **Disable it first** for a few weeks instead. Disabling is reversible at any time and breaks the same things, so you learn what depends on it safely.
- **Use the longest waiting period**: `aws kms schedule-key-deletion --key-id $KEY --pending-window-in-days 30`.
- **Re-encrypt data first**: S3 objects need copying with a new key, EBS snapshots copying with a new key, RDS a snapshot copy and restore.
- **AWS managed keys** (`aws/s3`, `aws/ebs`) can't be scheduled for deletion; this only happens to customer managed keys.
- Multi-Region primary keys can't be deleted until their replicas are deleted.

## Questions

### How do I cancel a KMS key deletion?

Run aws kms cancel-key-deletion with the key ID during the waiting period, then aws kms enable-key, because the key returns in the Disabled state.

### How long is the KMS key deletion waiting period?

Between 7 and 30 days, chosen when deletion is scheduled. The default is 30 days.

### Can I recover data after a KMS key is deleted?

No. Once the waiting period ends, the key material is gone and data encrypted only under that key can't be decrypted.

## When this happens away from your desk

A key scheduled for deletion breaks things quietly at first and then everywhere at once. CloudConsole, a phone app for AWS, is being built to show alarms and logs on your phone, so a burst of decrypt failures is visible early in the waiting period.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Delete an AWS KMS key](https://docs.aws.amazon.com/kms/latest/developerguide/deleting-keys.html)
- [Key states of AWS KMS keys](https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html)

## Related

- [KMS AccessDeniedException when reading an encrypted S3 object or secret](https://cloudconsole.dev/errors/kms-access-denied)
- [How to find who deleted a resource in AWS](https://cloudconsole.dev/how-to/find-who-deleted-aws-resource)
- [CloudTrail in CloudWatch Logs Insights: who did what](https://cloudconsole.dev/logs-insights/cloudtrail-who-did-what)
- [S3 AccessDenied: Access Denied when calling an S3 operation](https://cloudconsole.dev/errors/s3-access-denied)
- [You can't create this secret because a secret with this name is already scheduled for deletion](https://cloudconsole.dev/errors/secretsmanager-secret-scheduled-for-deletion)
- [AccessDeniedException: User is not authorized to perform this action because no identity-based policy allows it](https://cloudconsole.dev/errors/accessdenied-no-identity-based-policy-allows)

---

Source: https://cloudconsole.dev/errors/kms-key-pending-deletion

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
