Here's the scenario - I have a CloudFormation Stack which contains a web app. The Stack has an RDS instance and an ECS Cluster & Service which rely on it. I'm working with the Python form of the CDK.
In the production environment, if I'm creating the Stack, I'd want the RDS instance to start itself from a snapshot. That's fine and I can use rds.DatabaseInstanceFromSnapshot. But on subsequent deploys to that Stack, I don't want the DB to re-sync to a snapshot - since it's the production environment, it should now be the most up-to-date data I have and I wouldn't want it to be rolled back. However, I do still want to have that DB instance be able to be referred to and managed in the code. For example, if I want to change whether minor updates are automatically allowed, I want to be able to change that flag on the instance and deploy the Stack and have that picked up.
I'm uncertain how to achieve this. I tried putting a flag I'd pass in during updates so that the code used rds.DatabaseInstanceFromSnapshot on creation and then rds.DatabaseInstance on updates. However, the CDK seems to see these as distinct resources even if they are created with the same ID and ends up creating a new instance on updates.
I know I can use DatabaseInstanceBase.from_database_instance_attributes to look up an existing DB but my understanding is that returned instance would be read-only. That puts me in a paradigm in which the CDK can no longer manage the RDS instance after the initial deployment from a snapshot, which is not desired.
How can I tell the CDK "if creating, load the DB from a snapshot, otherwise behave like a normal RDS instance" while maintaining the ability to control that existing instance? I also flirted with making a CustomResource but that seemed to introduce new complexities (and the RestoreDBInstanceFromDBSnapshotCommand didn't seem to accept all the parameters that the CDK's RDS instances normally do).