You want to automatically stop an RDS instance that has been restarted after "exceeding the maximum allowed time being stopped" so that developers can maintain quickly accessible test setups at reasonable cost without the need to wait for the potentially fairly long restoration of new instances from large snapshots.

Concepts

TBD

Implementation

This provisions three conceptually independent components via an embedded stack for convenience (they can also be deployed independently for advanced use cases):

  1. A Lambda function that is indirectly subscribed to RDS event notifications of type 'db-instance' via an SNS topic. The function ingests all these events as custom events into CloudWatch Events to allow using its convenient and unified rules engine instead of custom code.

  2. A CloudWatch Events rule that matches only the RDS 'db-instance' events with the message 'DB instance is being started due to it exceeding the maximum allowed time being stopped'.

  3. A Step Functions state machine that is triggered by the matched CloudWatch event. The state machine will wait a configurable time and then stop the RDS instance via another Lambda function (default wait is 48 minutes, i.e. a bit shorter than the instance hour that is payed already).

Notes

There are a couple of things worth mentioning:

Step-by-step guide

Provision the rds-automatic-restart-mitigation.yaml CloudFormation template in the desired region(s):

  1. TBD

You may also want to use visual panels to communicate related information, tips or things users need to be aware of.

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.



Related issues