Currently to use this library all initialization code must be in the same stack as the database creation. This is problematic as errors in initialization leave the entire database in a ROLLBACK state which (as far as I can tell so far) requires that the database be deleted.
Attempting to move initialization code to a different stack results in cdk circular reference errors where I believe this is the offending line:
but if there are existing dependencies (i.e. stack1 already depends on stack2), then it is important to make the connection in the dependent stack (i.e. stack1).
So we should be able to achieve the same effect by making making the call on the handler rather that on the database
Currently to use this library all initialization code must be in the same stack as the database creation. This is problematic as errors in initialization leave the entire database in a ROLLBACK state which (as far as I can tell so far) requires that the database be deleted.
Attempting to move initialization code to a different stack results in cdk circular reference errors where I believe this is the offending line:
https://github.com/berenddeboer/cdk-rds-sql/blob/2791bb9628ea18673153da44dbd791d3062d3082/src/provider.ts#L88
The initialization stack depends on the database but the above line causes the database to also depend on initialization.
As discussed in this SO: https://stackoverflow.com/questions/77407725/aws-cdk-non-obvious-cyclic-dependency-between-fargate-task-and-rds
Which references the EC2 docs which state:
So we should be able to achieve the same effect by making making the call on the handler rather that on the database