(aws-secretsmanager): Creating RotationSchedule when rotation lambda and secret are in different stack fails due to cyclic reference #33336
Labels
@aws-cdk/aws-secretsmanager
Related to AWS Secrets Manager
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p3
Describe the bug
Currently when creating a RotationSchedule (either directly or using
secret.addRotationSchedule
) for a secret when the rotation lambda is in a different stack will causecdk synth
to fail with a cyclic reference error.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
We should be able to create a RotationSchedule for a secret even if the lambda function exists in another stack
Current Behavior
Currently when creating a RotationSchedule (either directly or using
secret.addRotationSchedule
) for a secret when the rotation lambda is in a different stack.cdk synth
will fail with the below errorUnpacking the above, the RotationSchedule resource has a dependency on the generated
AWS::Lambda::Permission
which was added via #26512.Even when using an aws-cdk version earlier than the change eg) v2.92.0 the request will fail with the below error
I suspect this is because the lambda function needs to
!Ref TestSecret
for permissions and the RotationSchedule needsrotationLambdaArn: !GetAtt TestLambda.arn
Reproduction Steps
Repo: https://github.com/jacklin213/secret-rotation-lambda
app.ts
lambda-stack.ts
secret-stack.ts
Then run
cdk synth
to see the issuePossible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.178.1 (build ae342cb)
Framework Version
No response
Node.js Version
v18.17.0
OS
Windows
Language
TypeScript
Language Version
5.6.3
Other information
No response
The text was updated successfully, but these errors were encountered: