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 →
- Fix the network path: the Lambda must reach both the DB and the
secretsmanagerendpoint - Remove the stale stage:
aws secretsmanager update-secret-version-stage --secret-id prod/db --version-stage AWSPENDING --remove-from-version-id <id> - 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).
More on CloudFormation, CloudWatch, KMS, Secrets and Cost
Updating a stack fails: `Stack:arn:aws:cloudformation:...:stack/app/... is in ROLLBACK_COMPLETE state and can not be updated.`BeginnerA stack is stuck in `UPDATE_ROLLBACK_FAILED`.AdvancedA pipeline fails with `An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed.`Beginner`InsufficientCapabilitiesException: Requires capabilities : [CAPABILITY_NAMED_IAM]`.BeginnerStack deletion ends in `DELETE_FAILED` with `The bucket you tried to delete is not empty` on an S3 bucket resource.IntermediateDrift detection shows `MODIFIED` on a security group and an RDS instance that someone changed in the console. How do you reconcile?Advanced