rds-database-running-scheduler 0.2.7 → 0.3.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 +94 -50
- package/API.md +94 -43
- package/README.md +41 -22
- package/assets/funcs/running-schedule.lambda/index.js +306 -80
- package/assets/funcs/running-schedule.lambda/index.js.map +4 -4
- package/lib/constructs/rds-database-running-scheduler.d.ts +25 -9
- package/lib/constructs/rds-database-running-scheduler.js +23 -12
- package/lib/funcs/running-schedule.lambda.d.ts +10 -4
- package/lib/funcs/running-schedule.lambda.js +39 -21
- package/lib/index.d.ts +3 -0
- package/lib/index.js +4 -1
- package/lib/stacks/rds-database-running-schedule-stack.d.ts +11 -7
- package/lib/stacks/rds-database-running-schedule-stack.js +6 -6
- package/package.json +17 -18
package/API.md
CHANGED
|
@@ -9,7 +9,9 @@ CDK construct that provisions a durable Lambda workflow and EventBridge schedule
|
|
|
9
9
|
The Lambda discovers matching resources account-wide via the Resource Groups
|
|
10
10
|
Tagging API, deduplicates Aurora cluster member instances when the parent
|
|
11
11
|
cluster is also tagged, and controls each remaining resource using the
|
|
12
|
-
region encoded in its ARN.
|
|
12
|
+
region encoded in its ARN. When `notification.slack` is set, the Lambda
|
|
13
|
+
posts progress and results to Slack; otherwise Secrets Manager lookup,
|
|
14
|
+
Slack API calls, and related IAM grants are skipped.
|
|
13
15
|
|
|
14
16
|
#### Initializers <a name="Initializers" id="rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer"></a>
|
|
15
17
|
|
|
@@ -23,7 +25,7 @@ new RDSDatabaseRunningScheduler(scope: Construct, id: string, props: RDSDatabase
|
|
|
23
25
|
| --- | --- | --- |
|
|
24
26
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | Parent construct scope. |
|
|
25
27
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer.parameter.id">id</a></code> | <code>string</code> | Construct identifier. |
|
|
26
|
-
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer.parameter.props">props</a></code> | <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps">RDSDatabaseRunningSchedulerProps</a></code> | Scheduler configuration. |
|
|
28
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer.parameter.props">props</a></code> | <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps">RDSDatabaseRunningSchedulerProps</a></code> | Scheduler configuration, including optional notification channels. |
|
|
27
29
|
|
|
28
30
|
---
|
|
29
31
|
|
|
@@ -47,7 +49,7 @@ Construct identifier.
|
|
|
47
49
|
|
|
48
50
|
- *Type:* <a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps">RDSDatabaseRunningSchedulerProps</a>
|
|
49
51
|
|
|
50
|
-
Scheduler configuration.
|
|
52
|
+
Scheduler configuration, including optional notification channels.
|
|
51
53
|
|
|
52
54
|
---
|
|
53
55
|
|
|
@@ -154,8 +156,8 @@ The tree node.
|
|
|
154
156
|
|
|
155
157
|
CDK stack that provisions scheduled start/stop control for tagged RDS resources in the deployment account.
|
|
156
158
|
|
|
157
|
-
Delegates resource discovery, cluster-priority deduplication,
|
|
158
|
-
execution to {@link RDSDatabaseRunningScheduler}.
|
|
159
|
+
Delegates resource discovery, cluster-priority deduplication, start/stop
|
|
160
|
+
execution, and optional Slack notifications to {@link RDSDatabaseRunningScheduler}.
|
|
159
161
|
|
|
160
162
|
#### Initializers <a name="Initializers" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer"></a>
|
|
161
163
|
|
|
@@ -169,7 +171,7 @@ new RDSDatabaseRunningScheduleStack(scope: Construct, id: string, props: RDSData
|
|
|
169
171
|
| --- | --- | --- |
|
|
170
172
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | Parent construct scope. |
|
|
171
173
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer.parameter.id">id</a></code> | <code>string</code> | Stack identifier. |
|
|
172
|
-
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer.parameter.props">props</a></code> | <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps">RDSDatabaseRunningScheduleStackProps</a></code> | Stack configuration. |
|
|
174
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStack.Initializer.parameter.props">props</a></code> | <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps">RDSDatabaseRunningScheduleStackProps</a></code> | Stack configuration, including optional notification channels. |
|
|
173
175
|
|
|
174
176
|
---
|
|
175
177
|
|
|
@@ -193,7 +195,7 @@ Stack identifier.
|
|
|
193
195
|
|
|
194
196
|
- *Type:* <a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps">RDSDatabaseRunningScheduleStackProps</a>
|
|
195
197
|
|
|
196
|
-
Stack configuration.
|
|
198
|
+
Stack configuration, including optional notification channels.
|
|
197
199
|
|
|
198
200
|
---
|
|
199
201
|
|
|
@@ -1112,6 +1114,43 @@ Whether termination protection is enabled for this stack.
|
|
|
1112
1114
|
|
|
1113
1115
|
## Structs <a name="Structs" id="Structs"></a>
|
|
1114
1116
|
|
|
1117
|
+
### Notification <a name="Notification" id="rds-database-running-scheduler.Notification"></a>
|
|
1118
|
+
|
|
1119
|
+
Notification channel configuration for the scheduler workflow.
|
|
1120
|
+
|
|
1121
|
+
Omit a channel (or the whole object) to disable that channel.
|
|
1122
|
+
Additional channels can be added here in the future without changing top-level props.
|
|
1123
|
+
|
|
1124
|
+
#### Initializer <a name="Initializer" id="rds-database-running-scheduler.Notification.Initializer"></a>
|
|
1125
|
+
|
|
1126
|
+
```typescript
|
|
1127
|
+
import { Notification } from 'rds-database-running-scheduler'
|
|
1128
|
+
|
|
1129
|
+
const notification: Notification = { ... }
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
#### Properties <a name="Properties" id="Properties"></a>
|
|
1133
|
+
|
|
1134
|
+
| **Name** | **Type** | **Description** |
|
|
1135
|
+
| --- | --- | --- |
|
|
1136
|
+
| <code><a href="#rds-database-running-scheduler.Notification.property.slack">slack</a></code> | <code><a href="#rds-database-running-scheduler.SlackNotification">SlackNotification</a></code> | Optional Slack notification settings. |
|
|
1137
|
+
|
|
1138
|
+
---
|
|
1139
|
+
|
|
1140
|
+
##### `slack`<sup>Optional</sup> <a name="slack" id="rds-database-running-scheduler.Notification.property.slack"></a>
|
|
1141
|
+
|
|
1142
|
+
```typescript
|
|
1143
|
+
public readonly slack: SlackNotification;
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
- *Type:* <a href="#rds-database-running-scheduler.SlackNotification">SlackNotification</a>
|
|
1147
|
+
|
|
1148
|
+
Optional Slack notification settings.
|
|
1149
|
+
|
|
1150
|
+
Presence enables Slack.
|
|
1151
|
+
|
|
1152
|
+
---
|
|
1153
|
+
|
|
1115
1154
|
### RDSDatabaseRunningSchedulerProps <a name="RDSDatabaseRunningSchedulerProps" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps"></a>
|
|
1116
1155
|
|
|
1117
1156
|
Properties for the RDS database running scheduler construct.
|
|
@@ -1128,26 +1167,14 @@ const rDSDatabaseRunningSchedulerProps: RDSDatabaseRunningSchedulerProps = { ...
|
|
|
1128
1167
|
|
|
1129
1168
|
| **Name** | **Type** | **Description** |
|
|
1130
1169
|
| --- | --- | --- |
|
|
1131
|
-
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.secrets">secrets</a></code> | <code><a href="#rds-database-running-scheduler.Secrets">Secrets</a></code> | Secret references used by the Lambda workflow. |
|
|
1132
1170
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.targetResource">targetResource</a></code> | <code><a href="#rds-database-running-scheduler.TargetResource">TargetResource</a></code> | Tag filter to select RDS instances and clusters. |
|
|
1133
1171
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.enableScheduling">enableScheduling</a></code> | <code>boolean</code> | Enables or disables both start and stop schedules. |
|
|
1172
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.notification">notification</a></code> | <code><a href="#rds-database-running-scheduler.Notification">Notification</a></code> | Optional notification channels. |
|
|
1134
1173
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.startSchedule">startSchedule</a></code> | <code><a href="#rds-database-running-scheduler.Schedule">Schedule</a></code> | Optional override for start schedule cron configuration. |
|
|
1135
1174
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.stopSchedule">stopSchedule</a></code> | <code><a href="#rds-database-running-scheduler.Schedule">Schedule</a></code> | Optional override for stop schedule cron configuration. |
|
|
1136
1175
|
|
|
1137
1176
|
---
|
|
1138
1177
|
|
|
1139
|
-
##### `secrets`<sup>Required</sup> <a name="secrets" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.secrets"></a>
|
|
1140
|
-
|
|
1141
|
-
```typescript
|
|
1142
|
-
public readonly secrets: Secrets;
|
|
1143
|
-
```
|
|
1144
|
-
|
|
1145
|
-
- *Type:* <a href="#rds-database-running-scheduler.Secrets">Secrets</a>
|
|
1146
|
-
|
|
1147
|
-
Secret references used by the Lambda workflow.
|
|
1148
|
-
|
|
1149
|
-
---
|
|
1150
|
-
|
|
1151
1178
|
##### `targetResource`<sup>Required</sup> <a name="targetResource" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.targetResource"></a>
|
|
1152
1179
|
|
|
1153
1180
|
```typescript
|
|
@@ -1170,6 +1197,23 @@ public readonly enableScheduling: boolean;
|
|
|
1170
1197
|
|
|
1171
1198
|
Enables or disables both start and stop schedules.
|
|
1172
1199
|
|
|
1200
|
+
Default: `true`.
|
|
1201
|
+
|
|
1202
|
+
---
|
|
1203
|
+
|
|
1204
|
+
##### `notification`<sup>Optional</sup> <a name="notification" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.notification"></a>
|
|
1205
|
+
|
|
1206
|
+
```typescript
|
|
1207
|
+
public readonly notification: Notification;
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
- *Type:* <a href="#rds-database-running-scheduler.Notification">Notification</a>
|
|
1211
|
+
|
|
1212
|
+
Optional notification channels.
|
|
1213
|
+
|
|
1214
|
+
Set `notification.slack` to enable Slack; omit it to skip secret lookup,
|
|
1215
|
+
Slack API calls, and related IAM grants.
|
|
1216
|
+
|
|
1173
1217
|
---
|
|
1174
1218
|
|
|
1175
1219
|
##### `startSchedule`<sup>Optional</sup> <a name="startSchedule" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.startSchedule"></a>
|
|
@@ -1224,9 +1268,9 @@ const rDSDatabaseRunningScheduleStackProps: RDSDatabaseRunningScheduleStackProps
|
|
|
1224
1268
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.synthesizer">synthesizer</a></code> | <code>aws-cdk-lib.IStackSynthesizer</code> | Synthesis method to use while deploying this stack. |
|
|
1225
1269
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.tags">tags</a></code> | <code>{[ key: string ]: string}</code> | Tags that will be applied to the Stack. |
|
|
1226
1270
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.terminationProtection">terminationProtection</a></code> | <code>boolean</code> | Whether to enable termination protection for this stack. |
|
|
1227
|
-
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.secrets">secrets</a></code> | <code><a href="#rds-database-running-scheduler.Secrets">Secrets</a></code> | Secret references required by the scheduler construct. |
|
|
1228
1271
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.targetResource">targetResource</a></code> | <code><a href="#rds-database-running-scheduler.TargetResource">TargetResource</a></code> | Tag filter used to select target RDS resources. |
|
|
1229
|
-
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.enableScheduling">enableScheduling</a></code> | <code>boolean</code> | Enables or disables
|
|
1272
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.enableScheduling">enableScheduling</a></code> | <code>boolean</code> | Enables or disables both start and stop schedules. |
|
|
1273
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.notification">notification</a></code> | <code><a href="#rds-database-running-scheduler.Notification">Notification</a></code> | Optional notification channels. |
|
|
1230
1274
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.startSchedule">startSchedule</a></code> | <code><a href="#rds-database-running-scheduler.Schedule">Schedule</a></code> | Optional cron configuration for start operations. |
|
|
1231
1275
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.stopSchedule">stopSchedule</a></code> | <code><a href="#rds-database-running-scheduler.Schedule">Schedule</a></code> | Optional cron configuration for stop operations. |
|
|
1232
1276
|
|
|
@@ -1476,39 +1520,44 @@ Whether to enable termination protection for this stack.
|
|
|
1476
1520
|
|
|
1477
1521
|
---
|
|
1478
1522
|
|
|
1479
|
-
##### `
|
|
1523
|
+
##### `targetResource`<sup>Required</sup> <a name="targetResource" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.targetResource"></a>
|
|
1480
1524
|
|
|
1481
1525
|
```typescript
|
|
1482
|
-
public readonly
|
|
1526
|
+
public readonly targetResource: TargetResource;
|
|
1483
1527
|
```
|
|
1484
1528
|
|
|
1485
|
-
- *Type:* <a href="#rds-database-running-scheduler.
|
|
1529
|
+
- *Type:* <a href="#rds-database-running-scheduler.TargetResource">TargetResource</a>
|
|
1486
1530
|
|
|
1487
|
-
|
|
1531
|
+
Tag filter used to select target RDS resources.
|
|
1488
1532
|
|
|
1489
1533
|
---
|
|
1490
1534
|
|
|
1491
|
-
##### `
|
|
1535
|
+
##### `enableScheduling`<sup>Optional</sup> <a name="enableScheduling" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.enableScheduling"></a>
|
|
1492
1536
|
|
|
1493
1537
|
```typescript
|
|
1494
|
-
public readonly
|
|
1538
|
+
public readonly enableScheduling: boolean;
|
|
1495
1539
|
```
|
|
1496
1540
|
|
|
1497
|
-
- *Type:*
|
|
1541
|
+
- *Type:* boolean
|
|
1498
1542
|
|
|
1499
|
-
|
|
1543
|
+
Enables or disables both start and stop schedules.
|
|
1544
|
+
|
|
1545
|
+
Default: `true`.
|
|
1500
1546
|
|
|
1501
1547
|
---
|
|
1502
1548
|
|
|
1503
|
-
##### `
|
|
1549
|
+
##### `notification`<sup>Optional</sup> <a name="notification" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.notification"></a>
|
|
1504
1550
|
|
|
1505
1551
|
```typescript
|
|
1506
|
-
public readonly
|
|
1552
|
+
public readonly notification: Notification;
|
|
1507
1553
|
```
|
|
1508
1554
|
|
|
1509
|
-
- *Type:*
|
|
1555
|
+
- *Type:* <a href="#rds-database-running-scheduler.Notification">Notification</a>
|
|
1556
|
+
|
|
1557
|
+
Optional notification channels.
|
|
1510
1558
|
|
|
1511
|
-
|
|
1559
|
+
Set `notification.slack` to enable Slack; omit it to skip secret lookup,
|
|
1560
|
+
Slack API calls, and related IAM grants.
|
|
1512
1561
|
|
|
1513
1562
|
---
|
|
1514
1563
|
|
|
@@ -1607,35 +1656,37 @@ Weekday field in cron expression.
|
|
|
1607
1656
|
|
|
1608
1657
|
---
|
|
1609
1658
|
|
|
1610
|
-
###
|
|
1659
|
+
### SlackNotification <a name="SlackNotification" id="rds-database-running-scheduler.SlackNotification"></a>
|
|
1660
|
+
|
|
1661
|
+
Slack notification settings.
|
|
1611
1662
|
|
|
1612
|
-
|
|
1663
|
+
Providing this object (via `notification.slack`) enables Slack notifications.
|
|
1613
1664
|
|
|
1614
|
-
#### Initializer <a name="Initializer" id="rds-database-running-scheduler.
|
|
1665
|
+
#### Initializer <a name="Initializer" id="rds-database-running-scheduler.SlackNotification.Initializer"></a>
|
|
1615
1666
|
|
|
1616
1667
|
```typescript
|
|
1617
|
-
import {
|
|
1668
|
+
import { SlackNotification } from 'rds-database-running-scheduler'
|
|
1618
1669
|
|
|
1619
|
-
const
|
|
1670
|
+
const slackNotification: SlackNotification = { ... }
|
|
1620
1671
|
```
|
|
1621
1672
|
|
|
1622
1673
|
#### Properties <a name="Properties" id="Properties"></a>
|
|
1623
1674
|
|
|
1624
1675
|
| **Name** | **Type** | **Description** |
|
|
1625
1676
|
| --- | --- | --- |
|
|
1626
|
-
| <code><a href="#rds-database-running-scheduler.
|
|
1677
|
+
| <code><a href="#rds-database-running-scheduler.SlackNotification.property.secretName">secretName</a></code> | <code>string</code> | Name of the Slack API secret in AWS Secrets Manager (`token` and `channel`). |
|
|
1627
1678
|
|
|
1628
1679
|
---
|
|
1629
1680
|
|
|
1630
|
-
##### `
|
|
1681
|
+
##### `secretName`<sup>Required</sup> <a name="secretName" id="rds-database-running-scheduler.SlackNotification.property.secretName"></a>
|
|
1631
1682
|
|
|
1632
1683
|
```typescript
|
|
1633
|
-
public readonly
|
|
1684
|
+
public readonly secretName: string;
|
|
1634
1685
|
```
|
|
1635
1686
|
|
|
1636
1687
|
- *Type:* string
|
|
1637
1688
|
|
|
1638
|
-
Name of the Slack API secret in AWS Secrets Manager.
|
|
1689
|
+
Name of the Slack API secret in AWS Secrets Manager (`token` and `channel`).
|
|
1639
1690
|
|
|
1640
1691
|
---
|
|
1641
1692
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
[](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, 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.
|
|
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. Slack notifications are optional via `notification.slack`. Default schedule: start 07:50 UTC, stop 19:05 UTC, Monday–Friday.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ This AWS CDK construct controls the start and stop of RDS DB instances and Auror
|
|
|
17
17
|
- **Region-aware RDS control**: Creates per-region RDS clients from each resource ARN so cross-region resources are handled correctly.
|
|
18
18
|
- **EventBridge Scheduler**: Cron-based start and stop schedules with configurable timezone, time, and weekdays.
|
|
19
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).
|
|
20
|
-
- **Slack notifications**:
|
|
20
|
+
- **Optional Slack notifications**: Set `notification.slack` to post schedule progress and per-resource results to Slack via Secrets Manager. Omit `notification` (or `notification.slack`) to skip secret lookup, Slack API calls, and related IAM grants.
|
|
21
21
|
- **Supported resources**: RDS DB instances and RDS Aurora clusters.
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
@@ -38,13 +38,26 @@ yarn add rds-database-running-scheduler
|
|
|
38
38
|
|
|
39
39
|
Use the **Construct** `RDSDatabaseRunningScheduler` when adding the scheduler into an existing Stack or any CDK scope.
|
|
40
40
|
|
|
41
|
+
With Slack notifications:
|
|
42
|
+
|
|
41
43
|
```typescript
|
|
42
44
|
import { TimeZone } from 'aws-cdk-lib';
|
|
43
45
|
import { RDSDatabaseRunningScheduler } from 'rds-database-running-scheduler';
|
|
44
46
|
|
|
45
47
|
new RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {
|
|
46
48
|
targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },
|
|
47
|
-
|
|
49
|
+
notification: { slack: { secretName: 'example/slack/webhook' } },
|
|
50
|
+
enableScheduling: true,
|
|
51
|
+
startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },
|
|
52
|
+
stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Without Slack notifications, omit `notification` (or omit `notification.slack`):
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
new RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {
|
|
60
|
+
targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },
|
|
48
61
|
enableScheduling: true,
|
|
49
62
|
startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },
|
|
50
63
|
stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },
|
|
@@ -61,7 +74,7 @@ const app = new App();
|
|
|
61
74
|
|
|
62
75
|
new RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {
|
|
63
76
|
targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },
|
|
64
|
-
|
|
77
|
+
notification: { slack: { secretName: 'example/slack/webhook' } },
|
|
65
78
|
enableScheduling: true,
|
|
66
79
|
startSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '50', hour: '7', week: 'MON-FRI' },
|
|
67
80
|
stopSchedule: { timezone: TimeZone.ASIA_TOKYO, minute: '5', hour: '19', week: 'MON-FRI' },
|
|
@@ -72,7 +85,7 @@ Tag your RDS instances or Aurora clusters with the same `tagKey` and one of the
|
|
|
72
85
|
|
|
73
86
|
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
87
|
|
|
75
|
-
|
|
88
|
+
When `notification.slack` is set, the secret in AWS Secrets Manager must contain JSON with `token` and `channel` fields:
|
|
76
89
|
|
|
77
90
|
```json
|
|
78
91
|
{
|
|
@@ -86,39 +99,45 @@ The Slack secret in AWS Secrets Manager must contain JSON with `token` and `chan
|
|
|
86
99
|
| Option | Type | Required | Description |
|
|
87
100
|
|--------|------|----------|-------------|
|
|
88
101
|
| `targetResource` | `TargetResource` | Yes | Tag key and values used to select RDS resources. |
|
|
89
|
-
| `
|
|
90
|
-
| `enableScheduling` | `boolean` | No | Whether schedules are enabled. Default: `true`. |
|
|
102
|
+
| `notification` | `Notification` | No | Notification channels. Set `notification.slack` to enable Slack. Omit to disable notifications. |
|
|
103
|
+
| `enableScheduling` | `boolean` | No | Whether start and stop schedules are enabled. Default: `true`. |
|
|
91
104
|
| `startSchedule` | `Schedule` | No | Start schedule. Default: 07:50 UTC, MON–FRI. |
|
|
92
105
|
| `stopSchedule` | `Schedule` | No | Stop schedule. Default: 19:05 UTC, MON–FRI. |
|
|
93
106
|
|
|
94
107
|
### Schedule
|
|
95
108
|
|
|
96
|
-
| Field | Type | Description |
|
|
97
|
-
|
|
98
|
-
| `timezone` | `TimeZone` | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |
|
|
99
|
-
| `minute` | `string` | Cron minute (for example `'50'`). |
|
|
100
|
-
| `hour` | `string` | Cron hour (for example `'7'`, `'19'`). |
|
|
101
|
-
| `week` | `string` | Cron week day (for example `'MON-FRI'`). |
|
|
109
|
+
| Field | Type | Required | Description |
|
|
110
|
+
|-------|------|----------|-------------|
|
|
111
|
+
| `timezone` | `TimeZone` | Yes | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |
|
|
112
|
+
| `minute` | `string` | No | Cron minute (for example `'50'`). |
|
|
113
|
+
| `hour` | `string` | No | Cron hour (for example `'7'`, `'19'`). |
|
|
114
|
+
| `week` | `string` | No | Cron week day (for example `'MON-FRI'`). |
|
|
102
115
|
|
|
103
116
|
### TargetResource
|
|
104
117
|
|
|
105
|
-
| Field | Type | Description |
|
|
106
|
-
|
|
107
|
-
| `tagKey` | `string` | Tag key to filter RDS resources. |
|
|
108
|
-
| `tagValues` | `string[]` | Tag values to match (resources with any of these values are targeted). |
|
|
118
|
+
| Field | Type | Required | Description |
|
|
119
|
+
|-------|------|----------|-------------|
|
|
120
|
+
| `tagKey` | `string` | Yes | Tag key to filter RDS resources. |
|
|
121
|
+
| `tagValues` | `string[]` | Yes | Tag values to match (resources with any of these values are targeted). |
|
|
122
|
+
|
|
123
|
+
### Notification
|
|
124
|
+
|
|
125
|
+
| Field | Type | Required | Description |
|
|
126
|
+
|-------|------|----------|-------------|
|
|
127
|
+
| `slack` | `SlackNotification` | No | Presence enables Slack notifications. |
|
|
109
128
|
|
|
110
|
-
###
|
|
129
|
+
### SlackNotification
|
|
111
130
|
|
|
112
|
-
| Field | Type | Description |
|
|
113
|
-
|
|
114
|
-
| `
|
|
131
|
+
| Field | Type | Required | Description |
|
|
132
|
+
|-------|------|----------|-------------|
|
|
133
|
+
| `secretName` | `string` | Yes | Secrets Manager secret name containing Slack `token` and `channel`. |
|
|
115
134
|
|
|
116
135
|
## Requirements
|
|
117
136
|
|
|
118
137
|
- **Node.js**: >= 20.0.0
|
|
119
138
|
- **AWS CDK**: ^2.232.0
|
|
120
139
|
- **constructs**: ^10.5.1
|
|
121
|
-
- **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, CloudWatch Logs
|
|
140
|
+
- **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, and CloudWatch Logs; RDS describe/start/stop permissions for targeted resources; Resource Groups Tagging API access for resource discovery. Secrets Manager access is required only when `notification.slack` is set.
|
|
122
141
|
|
|
123
142
|
## License
|
|
124
143
|
|