Nowadays, and mostly for very good reasons, there is a lot of enthusiasm around “going server-less”. Mostly however, people are thinking about deploying applications in a server-less manner. The very same principles can just as easily be applied to various DBA tasks using a few AWS services.
A typical use case for the “server-less DBA” is the fully automated management of AWS RDS for the Disaster Recovery site. The DR site in this case manifests as another AWS Account, and due to the nature of DR, the infrastructure in the DR account is deployed in a different geographical region than in the Production account. This adds a bit more complexity to the normal snapshot based backup-restore flow we would use to keep Development & or UAT databases in-sync with Production, but it still can be a relatively straightforward, automated process.
The exact solution is heavily dependent on your RTO, RPO and or DR requirements, but essentially it boils down to using a combination of the following; CloudWatch Events, RDS Event Notifications, Lambda functions, S3 storage and SNS topics.
1. An automatic snapshot is taken daily of the AWS RDS instance.
2. A scheduled CloudWatch Event or an alert on this RDS event-type triggers the Lambda function below.
3. A Lambda function;
a. picks up the latest automated snapshot of the RDS instance.
b. shares this snapshot with the DR account.
c. writes a notification to an SNS topic.
1. A Lambda function (triggered by the SNS notification from the Production account)
a. copies snapshot to the DR Region.
b. initiates snapshot based restore to DR RDS instance.
c. executes scripts against DR RDS instance, to change user privileges, stored paths, complete data obfuscation and other tasks as required.
The very simple scenario above is a high-level blueprint for a daily DR account refresh. By creating marginally more sophisticated Lambda functions and workflows, using for example JSON constants to store the list of database instances you want to execute the same procedures on, you have a simple framework consisting of a few Lambda functions manage your entire AWS RDS estate for Disaster Recovery and more mundane database refreshes.