Review the KMS key deletion waiting period

Assess deletion impacts and allow enough time to cancel an unintended deletion.

Description

deletion_window_in_days gives you time to cancel a scheduled KMS key deletion. Terraform defaults to 30 days and accepts 7–30.

Potential impact

Dependent services can stop as soon as a key is pending deletion. Once KMS deletes it, data that only this key could decrypt is unrecoverable.

Remediation

Identify the services and backups that use the key. Limit who can approve deletion and allow enough time to detect mistakes. If you cancel before the deadline, KMS leaves the key disabled. Re-enable it if still needed and test the dependent services.

Examples

Both examples keep the key and automatic rotation enabled. The first uses the default waiting period and the second shortens it to 10 days. Applying either configuration alone leaves the key in service.

Before

hcl
resource "aws_kms_key" "example" {
  description         = "KMS key 1"
  is_enabled          = true
  enable_key_rotation = true
}

After

hcl
resource "aws_kms_key" "example" {
  description             = "KMS key 1"
  is_enabled              = true
  enable_key_rotation     = true
  deletion_window_in_days = 10
}

References