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

Re-creating a secret fails: `InvalidRequestException: You can't create this secret because a secret with this name is already scheduled for deletion.`

BeginnerTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → A secret with that name was deleted with a recovery window (7–30 days) and is still recoverable. This often happens in IaC teardown and re-create cycles.

Diagnose →

aws secretsmanager describe-secret --secret-id dev/api-key --query '[Name,DeletedDate]'

Fix →

  1. To reuse it, restore it: aws secretsmanager restore-secret --secret-id dev/api-key
  2. For dev only, force deletion now: aws secretsmanager delete-secret --secret-id dev/api-key --force-delete-without-recovery

Prevent → For ephemeral environments, set recovery_window_in_days = 0 in Terraform, and keep a 30-day window in production.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost