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

Secrets Manager rotation fails, and the secret shows `AWSPENDING` stuck on a version.

AdvancedTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → The rotation Lambda failed in one of its four steps (createSecret, setSecret, testSecret, finishSecret). Common reasons: it cannot reach the DB (VPC or SG), it cannot reach the Secrets Manager endpoint from a private subnet, the DB user has no rights to change its password, or a previous failed rotation left AWSPENDING behind, which blocks the next try.

Diagnose →

aws secretsmanager describe-secret --secret-id prod/db --query '[RotationEnabled,LastRotatedDate,VersionIdsToStages]'
aws logs tail /aws/lambda/SecretsManagerRDSPostgreSQLRotationSingleUser --since 2h

Fix →

  1. Fix the network path: the Lambda must reach both the DB and the secretsmanager endpoint
  2. Remove the stale stage: aws secretsmanager update-secret-version-stage --secret-id prod/db --version-stage AWSPENDING --remove-from-version-id <id>
  3. Retry: aws secretsmanager rotate-secret --secret-id prod/db

Prevent → Prefer RDS managed master passwords, use the alternating-users strategy for apps, and alarm on rotation failures through EventBridge (RotationFailed).

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost