There's nothing stopping you from doing that.
I'd build it the following way:
- Create a CNAME record to point to the DNS record of the current database instance
- Reference that CNAME in your application
- Create a lambda that triggers daily
- Use that Lambda to create a new database instance from the known-good snapshot
- Afterwards the lambda should update the CNAME record from 1) to point to the new instance
- Then delete the old instance without making a final snapshot
You can leverage AWS Step Functions to orchestrate 4-6, because database operations take time and lambda runtime is finite.
Alternatively you can export the known good state of the DB as an SQL statement (research: sqldump) and then write a lambda function that gets triggered once per day, drops the old schema and creates a new schema from the known-good dump.
If the database is small, I'd go with the second alternative. For larger ones, I'd probably stick with the first. Beware that the second one will have a brief period where the application doesn't have access to a functioning database.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…