Registry / aws / aws-rds-database-running-scheduler

aws-rds-database-running-scheduler

JSON →
library0.3.5jsnpmunverified

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-scheduler
INSTALL
IMPORT
SIG · AWS-RDS-DATABASE-R
A
aws-rds-database-running-scheduler
awsjavascriptv0.3.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RDSDatabaseRunningScheduler
import { RDSDatabaseRunningScheduler } from 'aws-rds-database-running-scheduler';
const { RDSDatabaseRunningScheduler } = require('aws-rds-database-running-scheduler');
This is the primary construct for embedding the scheduler into an existing CDK stack. Use ESM import syntax.
RDSDatabaseRunningScheduleStack
import { RDSDatabaseRunningScheduleStack } from 'aws-rds-database-running-scheduler';
import RDSDatabaseRunningScheduleStack from 'aws-rds-database-running-scheduler';
Use this specific Stack construct when creating a dedicated CDK stack solely for the scheduler. It's a named import.
App
import { App, Stack } from 'aws-cdk-lib';
When using CDK constructs, you typically need to import `App` and `Stack` from `aws-cdk-lib` to define your application and environment.

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.

import { App, Stack } from 'aws-cdk-lib'; import { RDSDatabaseRunningScheduler } from 'aws-rds-database-running-scheduler'; import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; const app = new App(); const stack = new Stack(app, 'MyRdsSchedulerStack', { env: { account: process.env.CDK_DEFAULT_ACCOUNT ?? '', region: process.env.CDK_DEFAULT_REGION ?? '' } }); // Create a placeholder secret for Slack webhook (replace with your actual secret management) const slackWebhookSecret = new Secret(stack, 'SlackWebhookSecret', { secretName: 'example/slack/webhook', description: 'Secret for Slack webhook URL (for RDS scheduler notifications)', secretStringValue: process.env.SLACK_WEBHOOK_URL ?? 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' }); new RDSDatabaseRunningScheduler(stack, 'MyRDSScheduler', { targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] }, secrets: { slackSecretName: slackWebhookSecret.secretName }, enableScheduling: true, startSchedule: { timezone: 'Asia/Tokyo', minute: '50', hour: '7', week: 'MON-FRI' }, stopSchedule: { timezone: 'Asia/Tokyo', minute: '5', hour: '19', week: 'MON-FRI' } }); app.synth();
Debug
Known issues
breakingThis package requires Node.js version 20.0.0 or higher. Older Node.js versions are not supported and will lead to errors during CDK synthesis or deployment.
fix
Upgrade your Node.js environment to version 20.0.0 or newer (e.g., using nvm: `nvm install 20 && nvm use 20`).
affects: >=3.0.0
gotchaThe `targetResource.tagKey` and `targetResource.tagValues` must exactly match the tags applied to your RDS instances or Aurora clusters. Mismatched casing or values will result in resources not being managed by the scheduler.
fix
Carefully verify that the tags on your AWS RDS resources (both key and value) precisely match the configuration in your CDK code.
affects: >=3.0.0
gotchaThe `slackSecretName` property expects the name of an AWS Secrets Manager secret that contains the Slack webhook URL. If the secret does not exist or the Lambda function lacks permissions to access it, Slack notifications will fail silently or cause Lambda invocation errors.
fix
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.
affects: >=3.0.0
gotchaThe `timezone` string for `startSchedule` and `stopSchedule` must be a valid IANA timezone identifier (e.g., 'America/New_York', 'Europe/London', 'Asia/Tokyo'). Invalid timezone strings may lead to incorrect scheduling or deployment failures.
fix
Consult a list of IANA timezones and use a valid identifier for your desired schedule. Examples include 'UTC', 'America/Los_Angeles', 'Europe/Berlin'.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Invariant Violation: The construct ID 'MyRDSScheduler' is already in use by a sibling construct. Choose a unique ID for each construct within the same scope.
Attempting to create two constructs with the same ID within the same parent scope.
fix
Ensure each construct instance (e.g., `new RDSDatabaseRunningScheduler(...)`) has a unique string ID within its parent scope (e.g., `stack`).
Error: Unable to resolve object: Fn::Join: Invalid type for Fn::Join
Common CDK synthesis error indicating an issue with how references or intrinsic functions are used, often due to passing non-string values where strings are expected.
fix
Review the properties passed to `RDSDatabaseRunningSchedulerProps`, especially for `targetResource` and `secrets`, ensuring all values are correctly typed as strings or construct references.
TypeError: Cannot read properties of undefined (reading 'account')
CDK environment variables (CDK_DEFAULT_ACCOUNT, CDK_DEFAULT_REGION) are not set when synthesizing or deploying, and the stack's `env` property is not explicitly provided or correctly conditionally accessed.
fix
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"`).
Upgrade
Version history
0.3.5latest on npm
Audit
Dependencies
aws-cdk-librequiredCore AWS CDK constructs and types for defining cloud infrastructure.
constructsrequiredFundamental building blocks for AWS CDK applications, providing the construct programming model.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
aws-rds-database-running-scheduler — npm install aws-rds-database-running-scheduler · libregistry