rds-database-running-scheduler 0.1.10 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jsii CHANGED
@@ -8455,7 +8455,7 @@
8455
8455
  },
8456
8456
  "name": "rds-database-running-scheduler",
8457
8457
  "readme": {
8458
- "markdown": "# RDS Database Running Scheduler (AWS CDK v2)\n\n[![GitHub](https://img.shields.io/github/license/gammarers-aws-cdk-constructs/rds-database-running-scheduler?style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/blob/main/LICENSE)\n[![npm version](https://img.shields.io/npm/v/rds-database-running-scheduler?style=flat-square)](https://www.npmjs.com/package/rds-database-running-scheduler)\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/gammarers-aws-cdk-constructs/rds-database-running-scheduler/release.yml?branch=main&label=release&style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/actions/workflows/release.yml)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/gammarers-aws-cdk-constructs/rds-database-running-scheduler?sort=semver&style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/releases)\n\n[![View on Construct Hub](https://constructs.dev/badge?package=rds-database-running-scheduler)](https://constructs.dev/packages/rds-database-running-scheduler)\n\nThis AWS CDK construct controls the start and stop of RDS DB instances and Aurora clusters based on resource tags. EventBridge Scheduler invokes a durable Lambda function on a cron schedule so databases run only during defined working hours. The Lambda discovers tagged resources account-wide via the Resource Groups Tagging API and controls each resource using the region encoded in its ARN. Default schedule: start 07:50 UTC, stop 19:05 UTC, Monday–Friday.\n\n## Features\n\n- **Tag-based targeting**: Start and stop RDS DB instances and Aurora clusters that match a given tag key and values.\n- **Account-wide discovery**: Finds tagged RDS resources across all regions in the deployment account.\n- **Region-aware RDS control**: Creates per-region RDS clients from each resource ARN so cross-region resources are handled correctly.\n- **EventBridge Scheduler**: Cron-based start and stop schedules with configurable timezone, time, and weekdays.\n- **Lambda with Durable Execution**: A single durable run discovers resources by tag, starts or stops them, and polls until they reach the desired state (with timeout).\n- **Slack notifications**: Posts schedule progress and per-resource results to Slack using a secret stored in AWS Secrets Manager.\n- **Supported resources**: RDS DB instances and RDS Aurora clusters.\n\n## Installation\n\n**npm**\n\n```bash\nnpm install rds-database-running-scheduler\n```\n\n**yarn**\n\n```bash\nyarn add rds-database-running-scheduler\n```\n\n## Usage\n\nUse the **Construct** `RDSDatabaseRunningScheduler` when adding the scheduler into an existing Stack or any CDK scope.\n\n```typescript\nimport { TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduler } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n secrets: { slackSecretName: 'example/slack/webhook' },\n enableScheduling: true,\n startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },\n stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },\n});\n```\n\nUse the **Stack** `RDSDatabaseRunningScheduleStack` when you want a dedicated Stack that only contains the scheduler. Both accept the same props.\n\n```typescript\nimport { App, TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduleStack } from 'rds-database-running-scheduler';\n\nconst app = new App();\n\nnew RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n secrets: { slackSecretName: 'example/slack/webhook' },\n enableScheduling: true,\n startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },\n stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },\n});\n```\n\nTag your RDS instances or Aurora clusters with the same `tagKey` and one of the `tagValues` so they are included in the schedule.\n\nThe Slack secret in AWS Secrets Manager must contain JSON with `token` and `channel` fields:\n\n```json\n{\n \"token\": \"xoxb-...\",\n \"channel\": \"C0123456789\"\n}\n```\n\n## Options\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `targetResource` | `TargetResource` | Yes | Tag key and values used to select RDS resources. |\n| `secrets` | `Secrets` | Yes | Slack configuration. `slackSecretName`: Secrets Manager secret name for Slack (`token` and `channel`). |\n| `enableScheduling` | `boolean` | No | Whether schedules are enabled. Default: `true`. |\n| `startSchedule` | `Schedule` | No | Start schedule. Default: 07:50 UTC, MON–FRI. |\n| `stopSchedule` | `Schedule` | No | Stop schedule. Default: 19:05 UTC, MON–FRI. |\n\n### Schedule\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `timezone` | `TimeZone` | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |\n| `minute` | `string` | Cron minute (for example `'50'`). |\n| `hour` | `string` | Cron hour (for example `'7'`, `'19'`). |\n| `week` | `string` | Cron week day (for example `'MON-FRI'`). |\n\n### TargetResource\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `tagKey` | `string` | Tag key to filter RDS resources. |\n| `tagValues` | `string[]` | Tag values to match (resources with any of these values are targeted). |\n\n### Secrets\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `slackSecretName` | `string` | Secrets Manager secret name containing Slack `token` and `channel`. |\n\n## Requirements\n\n- **Node.js**: >= 20.0.0\n- **AWS CDK**: ^2.232.0\n- **constructs**: ^10.5.1\n- **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, CloudWatch Logs, and Secrets Manager; RDS start/stop permissions for targeted resources; Resource Groups Tagging API access for resource discovery.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n"
8458
+ "markdown": "# RDS Database Running Scheduler (AWS CDK v2)\n\n[![GitHub](https://img.shields.io/github/license/gammarers-aws-cdk-constructs/rds-database-running-scheduler?style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/blob/main/LICENSE)\n[![npm version](https://img.shields.io/npm/v/rds-database-running-scheduler?style=flat-square)](https://www.npmjs.com/package/rds-database-running-scheduler)\n[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/gammarers-aws-cdk-constructs/rds-database-running-scheduler/release.yml?branch=main&label=release&style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/actions/workflows/release.yml)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/gammarers-aws-cdk-constructs/rds-database-running-scheduler?sort=semver&style=flat-square)](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/releases)\n\n[![View on Construct Hub](https://constructs.dev/badge?package=rds-database-running-scheduler)](https://constructs.dev/packages/rds-database-running-scheduler)\n\nThis AWS CDK construct controls the start and stop of RDS DB instances and Aurora clusters based on resource tags. EventBridge Scheduler invokes a durable Lambda function on a cron schedule so databases run only during defined working hours. The Lambda discovers tagged resources account-wide via the Resource Groups Tagging API, deduplicates Aurora cluster member instances when the parent cluster is also tagged, and controls each remaining resource using the region encoded in its ARN. Default schedule: start 07:50 UTC, stop 19:05 UTC, Monday–Friday.\n\n## Features\n\n- **Tag-based targeting**: Start and stop RDS DB instances and Aurora clusters that match a given tag key and values.\n- **Account-wide discovery**: Finds tagged RDS resources across all regions in the deployment account.\n- **Cluster-priority deduplication**: When tag discovery returns both an Aurora cluster and its member DB instances, only the cluster is processed to avoid conflicting start/stop operations.\n- **Region-aware RDS control**: Creates per-region RDS clients from each resource ARN so cross-region resources are handled correctly.\n- **EventBridge Scheduler**: Cron-based start and stop schedules with configurable timezone, time, and weekdays.\n- **Lambda with Durable Execution**: A single durable run discovers resources by tag, starts or stops them, and polls until they reach the desired state (with timeout).\n- **Slack notifications**: Posts schedule progress and per-resource results to Slack using a secret stored in AWS Secrets Manager.\n- **Supported resources**: RDS DB instances and RDS Aurora clusters.\n\n## Installation\n\n**npm**\n\n```bash\nnpm install rds-database-running-scheduler\n```\n\n**yarn**\n\n```bash\nyarn add rds-database-running-scheduler\n```\n\n## Usage\n\nUse the **Construct** `RDSDatabaseRunningScheduler` when adding the scheduler into an existing Stack or any CDK scope.\n\n```typescript\nimport { TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduler } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n secrets: { slackSecretName: 'example/slack/webhook' },\n enableScheduling: true,\n startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },\n stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },\n});\n```\n\nUse the **Stack** `RDSDatabaseRunningScheduleStack` when you want a dedicated Stack that only contains the scheduler. Both accept the same props.\n\n```typescript\nimport { App, TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduleStack } from 'rds-database-running-scheduler';\n\nconst app = new App();\n\nnew RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n secrets: { slackSecretName: 'example/slack/webhook' },\n enableScheduling: true,\n startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },\n stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },\n});\n```\n\nTag your RDS instances or Aurora clusters with the same `tagKey` and one of the `tagValues` so they are included in the schedule.\n\nFor Aurora, tagging the cluster is sufficient. If member DB instances inherit the same tag, the Lambda automatically excludes them when the parent cluster is also targeted, so cluster-level start/stop is applied once without conflicting instance-level operations.\n\nThe Slack secret in AWS Secrets Manager must contain JSON with `token` and `channel` fields:\n\n```json\n{\n \"token\": \"xoxb-...\",\n \"channel\": \"C0123456789\"\n}\n```\n\n## Options\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `targetResource` | `TargetResource` | Yes | Tag key and values used to select RDS resources. |\n| `secrets` | `Secrets` | Yes | Slack configuration. `slackSecretName`: Secrets Manager secret name for Slack (`token` and `channel`). |\n| `enableScheduling` | `boolean` | No | Whether schedules are enabled. Default: `true`. |\n| `startSchedule` | `Schedule` | No | Start schedule. Default: 07:50 UTC, MON–FRI. |\n| `stopSchedule` | `Schedule` | No | Stop schedule. Default: 19:05 UTC, MON–FRI. |\n\n### Schedule\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `timezone` | `TimeZone` | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |\n| `minute` | `string` | Cron minute (for example `'50'`). |\n| `hour` | `string` | Cron hour (for example `'7'`, `'19'`). |\n| `week` | `string` | Cron week day (for example `'MON-FRI'`). |\n\n### TargetResource\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `tagKey` | `string` | Tag key to filter RDS resources. |\n| `tagValues` | `string[]` | Tag values to match (resources with any of these values are targeted). |\n\n### Secrets\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `slackSecretName` | `string` | Secrets Manager secret name containing Slack `token` and `channel`. |\n\n## Requirements\n\n- **Node.js**: >= 20.0.0\n- **AWS CDK**: ^2.232.0\n- **constructs**: ^10.5.1\n- **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, CloudWatch Logs, and Secrets Manager; RDS describe/start/stop permissions for targeted resources; Resource Groups Tagging API access for resource discovery.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n"
8459
8459
  },
8460
8460
  "repository": {
8461
8461
  "type": "git",
@@ -8472,6 +8472,7 @@
8472
8472
  "assembly": "rds-database-running-scheduler",
8473
8473
  "base": "aws-cdk-lib.Stack",
8474
8474
  "docs": {
8475
+ "remarks": "Delegates resource discovery, cluster-priority deduplication, and start/stop\nexecution to {@link RDSDatabaseRunningScheduler}.",
8475
8476
  "stability": "stable",
8476
8477
  "summary": "CDK stack that provisions scheduled start/stop control for tagged RDS resources in the deployment account."
8477
8478
  },
@@ -8483,7 +8484,7 @@
8483
8484
  },
8484
8485
  "locationInModule": {
8485
8486
  "filename": "src/stacks/rds-database-running-schedule-stack.ts",
8486
- "line": 33
8487
+ "line": 36
8487
8488
  },
8488
8489
  "parameters": [
8489
8490
  {
@@ -8518,7 +8519,7 @@
8518
8519
  "kind": "class",
8519
8520
  "locationInModule": {
8520
8521
  "filename": "src/stacks/rds-database-running-schedule-stack.ts",
8521
- "line": 25
8522
+ "line": 28
8522
8523
  },
8523
8524
  "name": "RDSDatabaseRunningScheduleStack",
8524
8525
  "symbolId": "src/stacks/rds-database-running-schedule-stack:RDSDatabaseRunningScheduleStack"
@@ -8631,7 +8632,7 @@
8631
8632
  "assembly": "rds-database-running-scheduler",
8632
8633
  "base": "constructs.Construct",
8633
8634
  "docs": {
8634
- "remarks": "The Lambda discovers matching resources account-wide via the Resource Groups\nTagging API and controls each resource using the region encoded in its ARN.",
8635
+ "remarks": "The Lambda discovers matching resources account-wide via the Resource Groups\nTagging API, deduplicates Aurora cluster member instances when the parent\ncluster is also tagged, and controls each remaining resource using the\nregion encoded in its ARN.",
8635
8636
  "stability": "stable",
8636
8637
  "summary": "CDK construct that provisions a durable Lambda workflow and EventBridge schedules to start/stop tagged RDS databases and clusters."
8637
8638
  },
@@ -8643,7 +8644,7 @@
8643
8644
  },
8644
8645
  "locationInModule": {
8645
8646
  "filename": "src/constructs/rds-database-running-scheduler.ts",
8646
- "line": 74
8647
+ "line": 76
8647
8648
  },
8648
8649
  "parameters": [
8649
8650
  {
@@ -8678,7 +8679,7 @@
8678
8679
  "kind": "class",
8679
8680
  "locationInModule": {
8680
8681
  "filename": "src/constructs/rds-database-running-scheduler.ts",
8681
- "line": 66
8682
+ "line": 68
8682
8683
  },
8683
8684
  "name": "RDSDatabaseRunningScheduler",
8684
8685
  "symbolId": "src/constructs/rds-database-running-scheduler:RDSDatabaseRunningScheduler"
@@ -8959,6 +8960,6 @@
8959
8960
  "symbolId": "src/constructs/rds-database-running-scheduler:TargetResource"
8960
8961
  }
8961
8962
  },
8962
- "version": "0.1.10",
8963
- "fingerprint": "bFMJ6MG0ILAgYQqUU4vbIbA23FCr7Kddt1h6Mb5Knps="
8963
+ "version": "0.2.0",
8964
+ "fingerprint": "6hKPS3BT1zXIOkRFZl/fJG7aNMDI/Kcd3s8SiD8JoZk="
8964
8965
  }
package/API.md CHANGED
@@ -7,7 +7,9 @@
7
7
  CDK construct that provisions a durable Lambda workflow and EventBridge schedules to start/stop tagged RDS databases and clusters.
8
8
 
9
9
  The Lambda discovers matching resources account-wide via the Resource Groups
10
- Tagging API and controls each resource using the region encoded in its ARN.
10
+ Tagging API, deduplicates Aurora cluster member instances when the parent
11
+ cluster is also tagged, and controls each remaining resource using the
12
+ region encoded in its ARN.
11
13
 
12
14
  #### Initializers <a name="Initializers" id="rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer"></a>
13
15
 
@@ -152,6 +154,9 @@ The tree node.
152
154
 
153
155
  CDK stack that provisions scheduled start/stop control for tagged RDS resources in the deployment account.
154
156
 
157
+ Delegates resource discovery, cluster-priority deduplication, and start/stop
158
+ execution to {@link RDSDatabaseRunningScheduler}.
159
+
155
160
  #### Initializers <a name="Initializers" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer"></a>
156
161
 
157
162
  ```typescript
package/README.md CHANGED
@@ -7,12 +7,13 @@
7
7
 
8
8
  [![View on Construct Hub](https://constructs.dev/badge?package=rds-database-running-scheduler)](https://constructs.dev/packages/rds-database-running-scheduler)
9
9
 
10
- This AWS CDK construct controls the start and stop of RDS DB instances and Aurora clusters based on resource tags. EventBridge Scheduler invokes a durable Lambda function on a cron schedule so databases run only during defined working hours. The Lambda discovers tagged resources account-wide via the Resource Groups Tagging API and controls each resource using the region encoded in its ARN. Default schedule: start 07:50 UTC, stop 19:05 UTC, Monday–Friday.
10
+ This AWS CDK construct controls the start and stop of RDS DB instances and Aurora clusters based on resource tags. EventBridge Scheduler invokes a durable Lambda function on a cron schedule so databases run only during defined working hours. The Lambda discovers tagged resources account-wide via the Resource Groups Tagging API, deduplicates Aurora cluster member instances when the parent cluster is also tagged, and controls each remaining resource using the region encoded in its ARN. Default schedule: start 07:50 UTC, stop 19:05 UTC, Monday–Friday.
11
11
 
12
12
  ## Features
13
13
 
14
14
  - **Tag-based targeting**: Start and stop RDS DB instances and Aurora clusters that match a given tag key and values.
15
15
  - **Account-wide discovery**: Finds tagged RDS resources across all regions in the deployment account.
16
+ - **Cluster-priority deduplication**: When tag discovery returns both an Aurora cluster and its member DB instances, only the cluster is processed to avoid conflicting start/stop operations.
16
17
  - **Region-aware RDS control**: Creates per-region RDS clients from each resource ARN so cross-region resources are handled correctly.
17
18
  - **EventBridge Scheduler**: Cron-based start and stop schedules with configurable timezone, time, and weekdays.
18
19
  - **Lambda with Durable Execution**: A single durable run discovers resources by tag, starts or stops them, and polls until they reach the desired state (with timeout).
@@ -69,6 +70,8 @@ new RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {
69
70
 
70
71
  Tag your RDS instances or Aurora clusters with the same `tagKey` and one of the `tagValues` so they are included in the schedule.
71
72
 
73
+ For Aurora, tagging the cluster is sufficient. If member DB instances inherit the same tag, the Lambda automatically excludes them when the parent cluster is also targeted, so cluster-level start/stop is applied once without conflicting instance-level operations.
74
+
72
75
  The Slack secret in AWS Secrets Manager must contain JSON with `token` and `channel` fields:
73
76
 
74
77
  ```json
@@ -115,7 +118,7 @@ The Slack secret in AWS Secrets Manager must contain JSON with `token` and `chan
115
118
  - **Node.js**: >= 20.0.0
116
119
  - **AWS CDK**: ^2.232.0
117
120
  - **constructs**: ^10.5.1
118
- - **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, CloudWatch Logs, and Secrets Manager; RDS start/stop permissions for targeted resources; Resource Groups Tagging API access for resource discovery.
121
+ - **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, CloudWatch Logs, and Secrets Manager; RDS describe/start/stop permissions for targeted resources; Resource Groups Tagging API access for resource discovery.
119
122
 
120
123
  ## License
121
124