Skip to main content

AWS RDS Database Running Scheduler

Project description

AWS RDS Database Running Schedule Stack

GitHub npm (scoped) PyPI Nuget GitHub Workflow Status (branch) GitHub release (latest SemVer)

View on Construct Hub

This AWS CDK Construct Stack controls the starting and stopping of RDS DB instances and clusters based on specified tags, ensuring they only run during working hours. It uses EventBridge Scheduler to trigger a StepFunctions State Machine at the start and end of the working hours(default 07:50(UTC) - 21:10(UTC)), which then starts or stops the databases depending on the mode.

[!WARNING] v2.3.0: Stack props add option resourceNamingOption default ResourceNamingType.DEFAULT is cdk generated name f you want to maintain compatibility with versions below v2.3.0, please include the following settings (ResourceNamingType.AUTO).

new RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {
  targetResource: {
    tagKey: 'WorkHoursRunning',
    tagValues: ['YES'],
  },
  resourceNamingOption: {
    type: ResourceNamingType.AUTO, // HERE
  },
});

Fixed

  • RDS Aurora Cluster
  • RDS Instance

Resources

This construct creating resource list.

  • EventBridge Scheduler execution role
  • EventBridge Scheduler
  • StepFunctions StateMahcine (star or stop controle)
  • StepFunctions StateMahcine execution role

Install

TypeScript

install by npm

npm install @gammarers/aws-rds-database-running-schedule-stack

install by yarn

yarn add @gammarers/aws-rds-database-running-schedule-stack

install by pnpm

pnpm add @gammarers/aws-rds-database-running-schedule-stack

install by bun

bun add @gammarers/aws-rds-database-running-schedule-stack

Python

pip install gammarers.aws-rds-database-running-schedule-stack

C# / .NET

dotnet add package Gammarers.CDK.AWS.RdsDatabaseRunningScheduleStack

Example

import { RDSDatabaseRunningScheduleStack, ResourceNamingType } from '@gammarer/aws-rds-database-running-schedule-stack';

new RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {
  targetResource: {
    tagKey: 'WorkHoursRunning', // already tagging to rds instance or cluster
    tagValues: ['YES'], // already tagging to rds instance or cluster
  },
  enableScheduling: true,
  startSchedule: {
    timezone: 'Asia/Tokyo',
    minute: '55',
    hour: '8',
    week: 'MON-FRI',
  },
  stopSchedule: {
    timezone: 'Asia/Tokyo',
    minute: '5',
    hour: '19',
    week: 'MON-FRI',
  },
  resourceNamingOption: {
    type: ResourceNamingType.AUTO, // DEFAULT or AUTO or CUSTOM
  },
  notifications: {
    emails: [ // "Incoming Sample Message - EMAIL"
      'foo@example.com',
      'bar@example.net',
    ],
    slack: { // "Incoming Sample Message - EMAIL"
      webhookSecretName: 'example/slack/webhook',
    },
  },
});

Incoming Sample Message

EMAIL

Slack

License

This project is licensed under the Apache-2.0 License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file gammarers_aws_rds_database_running_schedule_stack-2.6.8.tar.gz.

File metadata

File hashes

Hashes for gammarers_aws_rds_database_running_schedule_stack-2.6.8.tar.gz
Algorithm Hash digest
SHA256 6e2ee207ab8f2466b94bba2f684d4dcf3ec41b1fe22108ee9d18e5de06fdab6c
MD5 15e415f3120cf8eb5b212eaf6e151b7b
BLAKE2b-256 6869de4dd9fd4dd270f400934add1a02a7672ec35bc870247deeec03a33dd2e0

See more details on using hashes here.

File details

Details for the file gammarers_aws_rds_database_running_schedule_stack-2.6.8-py3-none-any.whl.

File metadata

File hashes

Hashes for gammarers_aws_rds_database_running_schedule_stack-2.6.8-py3-none-any.whl
Algorithm Hash digest
SHA256 832b3e13a461b9cee3d3d8205a78d95e1c6a63fa7e9a984dd65a2e392d33adb4
MD5 dd934017db10dc927352ff985bc5a583
BLAKE2b-256 787b1b2325d2dcb6cd1631558e7186984b0d9b60bf040a28337d6e3535d58212

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page