This AWS CDK construct provides an automated solution for managing the operational hours of Amazon RDS DB instances and Aurora clusters. It identifies target resources based on user-defined tags and leverages AWS EventBridge Scheduler to trigger a Lambda function at specified times, ensuring databases only run during active working hours. This significantly reduces costs for non-production environments. The current stable version is 3.1.4, with frequent patch and minor releases. Key differentiators include its tag-based targeting, 'Durable Execution' Lambda that polls for desired resource states, and optional Slack notifications for operational status. It supports cron-based scheduling with configurable timezones, times, and weekdays, enabling precise control over database availability and cost optimization.
npm install aws-rds-database-running-schedulerVerified import paths — ran on the pinned version, not inferred.
This code deploys the RDS Database Running Scheduler as a construct within a new AWS CDK stack. It configures the scheduler to manage RDS instances and Aurora clusters tagged with 'WorkHoursRunning=YES', setting a daily start/stop schedule for weekdays in the 'Asia/Tokyo' timezone. It also includes a placeholder for Slack notification secret.
Upgrade your Node.js environment to version 20.0.0 or newer (e.g., using nvm: `nvm install 20 && nvm use 20`).
Carefully verify that the tags on your AWS RDS resources (both key and value) precisely match the configuration in your CDK code.
Ensure the specified secret exists in AWS Secrets Manager, contains a valid Slack webhook URL, and the IAM role associated with the scheduler's Lambda function has `secretsmanager:GetSecretValue` permissions for that secret.
Consult a list of IANA timezones and use a valid identifier for your desired schedule. Examples include 'UTC', 'America/Los_Angeles', 'Europe/Berlin'.
Ensure each construct instance (e.g., `new RDSDatabaseRunningScheduler(...)`) has a unique string ID within its parent scope (e.g., `stack`).
Review the properties passed to `RDSDatabaseRunningSchedulerProps`, especially for `targetResource` and `secrets`, ensuring all values are correctly typed as strings or construct references.
Define the `env` property for your `Stack` with explicit `account` and `region` values, or ensure `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` are set in your environment (e.g., `export CDK_DEFAULT_ACCOUNT="123456789012"`).