Interview Prep/AWS/CloudFormation, CloudWatch, KMS, Secrets and Cost

Decrypt calls fail with `KMSInvalidStateException: arn:aws:kms:...:key/... is pending deletion.`

IntermediateTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → Someone scheduled the key for deletion (7–30 day waiting period). While pending, the key cannot be used, and everything encrypted with it stops working.

Diagnose →

aws kms describe-key --key-id <key-id> --query 'KeyMetadata.[KeyState,DeletionDate]'
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ScheduleKeyDeletion --max-results 5

Fix →

aws kms cancel-key-deletion --key-id <key-id>
aws kms enable-key --key-id <key-id>      # cancel leaves it Disabled

Prevent → Deny kms:ScheduleKeyDeletion through SCP except for a break-glass role, alarm on that CloudTrail event through EventBridge, and use the 30-day window.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost