-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
RDS Proxy: adding multiple proxies via addProxy
causes a circular dependency in the generated target groups
#25633
Comments
I didn't get a circular reference here. Could you please provide information as to which resources are coming from another stack, as well as the error message? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Here's the full error message:
|
@benbelow can you please provide a snippet which will actually produce this error? Like I said before, I didn't reproduce this with the snippet linked, which cuts some resources out that are referenced within your snippet |
The following code seems to repro the issue for me with no other dependencies / resources from my application.
|
Thanks for sharing this @benbelow, I've managed to reproduce it now. I was expecting that you were running into the error on I am not sure, but if I were to guess I think this line is causing trouble somehow. https://github.com/aws/aws-cdk/blob/bbdb16ad65b1217901f92782a74a6f13222cd684/packages/aws-cdk-lib/aws-rds/lib/proxy.ts#LL493C7-L493C7 But I'm not really sure why the first Proxy is depending on the second. Thanks for reporting! |
Is there any update on this or a workaround? |
Hi folks, this is an issue for us too - any new updates on this? Thanks. |
Any updates in regards to workarounds or solutions to this issue? |
Also blocked by this |
#28471) ### Description The related issue reports that deployment fails due to circular dependencies when multiple RDSProxy are created. The `DatabaseProxy` uses the `node.addDependency` method to ensure that the `CfnDBProxyTargetGroup` is created after the `DBCluster` and `DBInstance` are created (#12237). This works well for a single `DatabaseProxy`, but does not work well when multiple `DatabaseProxy` are created with `DatabaseCluster.addProxy`. When creating a `DatabaseProxy` with the `DatabaseCluster.addProxy` method, it is created as a child of the `DatabaseCluster`. https://github.com/aws/aws-cdk/blob/cd54c4239ec29182e30fd91634505df560d6e5f8/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L446 The `node.addDependency` method recursively sets dependencies on child Constructs, so if multiple `DatabaseProxy` are created as a child of a `DatabaseCluster` in the construct tree, multiple `DatabaseProxy` dependencies on each other. If the `addProxy` method is not used, the user initializes the `DatabaseProxy` directly and it does not become a child of `DatabaseCluster`. For example, ```ts new DatabaseProxy(stack, 'DBProxy', { proxyTarget: rds.ProxyTarget.fromCluster(cluster), vpc, }); ``` I believe this is the cause of the `these resources have a dependency cycle` error reported in the related issue. To correct this error, this PR uses `CfnResource.addDependency` instead of `node.addDependency` to avoid recurrent dependencies. Closes #25633 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
aws#28471) ### Description The related issue reports that deployment fails due to circular dependencies when multiple RDSProxy are created. The `DatabaseProxy` uses the `node.addDependency` method to ensure that the `CfnDBProxyTargetGroup` is created after the `DBCluster` and `DBInstance` are created (aws#12237). This works well for a single `DatabaseProxy`, but does not work well when multiple `DatabaseProxy` are created with `DatabaseCluster.addProxy`. When creating a `DatabaseProxy` with the `DatabaseCluster.addProxy` method, it is created as a child of the `DatabaseCluster`. https://github.com/aws/aws-cdk/blob/cd54c4239ec29182e30fd91634505df560d6e5f8/packages/aws-cdk-lib/aws-rds/lib/cluster.ts#L446 The `node.addDependency` method recursively sets dependencies on child Constructs, so if multiple `DatabaseProxy` are created as a child of a `DatabaseCluster` in the construct tree, multiple `DatabaseProxy` dependencies on each other. If the `addProxy` method is not used, the user initializes the `DatabaseProxy` directly and it does not become a child of `DatabaseCluster`. For example, ```ts new DatabaseProxy(stack, 'DBProxy', { proxyTarget: rds.ProxyTarget.fromCluster(cluster), vpc, }); ``` I believe this is the cause of the `these resources have a dependency cycle` error reported in the related issue. To correct this error, this PR uses `CfnResource.addDependency` instead of `node.addDependency` to avoid recurrent dependencies. Closes aws#25633 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
adding multiple proxies via
addProxy
causes a circular dependency in the generated target groups.Each target group declares an explicit dependency on the other.
Expected Behavior
Two proxies are generated independently
Current Behavior
CDK template cannot be deployed due to circular dependency
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.79.1
Framework Version
No response
Node.js Version
19.7.0
OS
MacOS
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: