Description
Check the actual key state in KMS. Enabled: false disables the key. PendingWindowInDays only sets the waiting period to use if CloudFormation later deletes it.
Potential impact
Reads, resource creation or backup recovery can fail when they need a disabled key or one pending deletion. After deletion, data that only this key can decrypt is lost.
Remediation
Find out why the key was disabled and whether it is still needed. If deletion is scheduled, cancel it in KMS before enabling the same key. Check application permissions. Adding a key back to the template cannot restore the original. Before retirement, make sure data and backups no longer depend on it.
Examples
PendingWindowInDays: 7 in the first template does not schedule deletion. The second enables the key. Omitting the waiting period still permits deletion, so limit deletion permissions separately.
Before
Resources:
AppKey:
Type: AWS::KMS::Key
Properties:
Enabled: false
PendingWindowInDays: 7
KeyPolicy:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action: kms:*
Resource: "*"
After
Resources:
AppKey:
Type: AWS::KMS::Key
Properties:
Enabled: true
KeyPolicy:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS: !Sub arn:aws:iam::${AWS::AccountId}:root
Action: kms:*
Resource: "*"