Skip to content

Commit a12d9eb

Browse files
authored
fix(rds): circular dependencies when creating multiple DatabaseProxies (#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*
1 parent 98ed6b3 commit a12d9eb

File tree

10 files changed

+905
-420
lines changed

10 files changed

+905
-420
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.proxy.js.snapshot/aws-cdk-rds-proxy.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)