Scheduling DB Instance Start/Stop Using Custom Tag

In this guide, you will automate the scheduling of AWS RDS DB Instances using Guardrails policies and a custom tag.

Turbot Guardrails' Instance Scheduling allows you to define pre-scheduled start and stop times for RDS DB Instances at the resource or account level. Automating scheduling ensures instances run only when needed, optimizing costs and improving efficiency.

Prerequisites

Step 1: Create the Schedule Tag Policy Setting

Navigate to Policies in the sidebar and click New Policy Setting in the top right to open the Create Policy Setting form.

For the Policy Type, search for RDS Schedule Tag and select Schedule Tag under AWS > RDS > DB Instance.

Create Policy Setting form with the Policy Type picker filtered to RDS Schedule Tag

Step 2: Select the Target Resource

For the Resource, search for where the policy should apply. You can select a specific DB instance, an account, or a folder to apply the schedule broadly.

Create Policy Setting form with the Resource picker filtered to Retail Banking

Step 3: Set the Value

Choose Enforce: Schedule per turbot_custom_schedule tag to enable tag-based scheduling. This tells Guardrails to read the schedule from a tag on each RDS instance. Click Create.

Create Policy Setting form with the Schedule Tag value set to Enforce: Schedule per turbot_custom_schedule tag

FieldValueDescription
SettingEnforce: Schedule per turbot_custom_schedule tagGuardrails reads the schedule from the specified tag on each instance.
PrecedenceRequired (default)Enforced on all descendants unless an exception is granted.

[!NOTE] Guardrails also supports scheduling for RDS DB Clusters via the AWS > RDS > DB Cluster > Schedule Tag policy.

Step 4: Create the Schedule Tag Name Policy Setting

Create a second policy setting for AWS > RDS > DB Instance > Schedule Tag > Name. This tells Guardrails which tag key to read the schedule from. Set the value to turbot_custom_schedule (or any tag key name you prefer) and apply it at the same resource level or higher in the hierarchy.

Create Policy Setting form with the Schedule Tag Name value set to turbot_custom_schedule

Step 5: Apply the Tag to the Instance

Apply a tag to the RDS DB Instance in the AWS Console (or via CLI or Terraform) with the exact key name you configured in Step 4 (for example, turbot_custom_schedule).

The tag value must be a Base64-encoded JSON cron expression defining start and stop times:

JSON format:

{"start": "* 8 * * MON-FRI", "stop": "* 16 * * MON-FRI"}

This schedule starts the instance at 8:00 AM and stops it at 4:00 PM, Monday through Friday (UTC).

Base64 encoded:

eyJzdGFydCI6ICIqIDggKiAqIE1PTi1GUkkiLCAic3RvcCI6ICIqIDE2ICogKiBNT04tRlJJIn0=

[!IMPORTANT] RDS tags require the value to be Base64-encoded because the JSON cron format contains characters that aren't valid in tag values.

Step 6: Review

Troubleshooting

IssueDescriptionGuide
Schedule Tag control in ErrorThe tag value may not be valid Base64 or the decoded JSON may have an invalid cron expression.Verify the Base64 encoding and ensure the JSON has valid start and stop cron fields.
Tag name doesn't matchThe Schedule Tag Name policy value must exactly match the tag key on the instance.Check both the policy value and the actual tag key on the instance in the AWS Console.
Schedule not triggeringGuardrails evaluates the schedule on each control run. The control may need time to run, or the instance may be in a state that prevents stop/start operations.Check the control's Logs tab for details on the evaluation.
Further assistanceIf the issue persists.Open a Support Ticket