-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(secretsmanager): RotationSchedule resource creation race causes some stack deployments to fail #26481
Comments
Thanks, this makes sense. We add the permission here in the code, but there isn't a convenient way I can see without escape hatches for the code to access the permission from here
|
The |
Ah neat, I never knew about this feature |
…condition (#26512) Setting up a `RotationSchedule` with `rotationLambda` could cause failures due to the lambda invoking permission and the`RotationSchedule` being created concurrently. This fix adds a dependency to ensure the policy is created first and to prevent race conditions. Closes #26481. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
When using CDK to set up a Secrets Manager RotationSchedule, creation of the
AWS::SecretsManager::RotationSchedule
resource can fail (in a small proportion of deployments) with the following error:From looking at the Stack events, I can see that the Lambda Invoke permission and the RotationSchedule are being created at the same time, so it's down to luck whether the RotationSchedule's test invoke succeeds or fails, though in most cases it seems to succeed. An explicit dependency to ensure the Lambda resource policy is created first would improve the deployment reliability.
Expected Behavior
The deployment succeeds reliably.
Current Behavior
The deployment failed with the above error in 2 out of 18 deployments.
Reproduction Steps
Create a new typescript CDK project:
Replace
lib/cdk-bug-stack.ts
with the following:A
cdk synth
shows that theSecretRotationSchedule49AED07D
resource has no dependency on theAWS::Lambda::Permission
resourceRotationLambdaInvokeN0a2GKfZP0JmDqDEVhhu6A0TUv3NyNbk4YMFKNc852E0E9A
.Possible Solution
Add an explicit dependency to ensure the Lambda resource policy is created before the
RotationSchedule
.Additional Information/Context
No response
CDK CLI Version
2.88.0 (build 5d497f9)
Framework Version
2.87.0
Node.js Version
v18.17.0
OS
MacOS 13.4.1 (c) (22F770820d)
Language
Typescript
Language Version
TypeScript (5.1.6)
Other information
No response
The text was updated successfully, but these errors were encountered: