rds-database-running-scheduler 0.5.3 → 0.6.1
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 +107 -37
- package/API.md +107 -9
- package/README.md +101 -24
- package/assets/funcs/running-schedule.lambda/index.js +2962 -758
- package/assets/funcs/running-schedule.lambda/index.js.map +4 -4
- package/lib/funcs/core/running-schedule-discovery.d.ts +31 -0
- package/lib/funcs/core/running-schedule-discovery.js +74 -0
- package/lib/funcs/core/running-schedule-errors.d.ts +7 -0
- package/lib/funcs/core/running-schedule-errors.js +13 -2
- package/lib/funcs/core/running-schedule-wait.d.ts +44 -18
- package/lib/funcs/core/running-schedule-wait.js +38 -20
- package/lib/funcs/running-schedule.lambda.d.ts +4 -27
- package/lib/funcs/running-schedule.lambda.js +221 -86
- package/lib/rds-database-running-schedule-stack.d.ts +1 -1
- package/lib/rds-database-running-schedule-stack.js +5 -3
- package/lib/rds-database-running-scheduler.d.ts +39 -8
- package/lib/rds-database-running-scheduler.js +126 -19
- package/lib/settings/consts.d.ts +22 -0
- package/lib/settings/consts.js +19 -2
- package/package.json +9 -5
package/.jsii
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"aws-cdk-lib": "^2.232.0",
|
|
11
|
-
"constructs": "^10.5.1"
|
|
11
|
+
"constructs": "^10.5.1",
|
|
12
|
+
"lambda-failure-detector": "^0.2.1"
|
|
12
13
|
},
|
|
13
14
|
"dependencyClosure": {
|
|
14
15
|
"@aws-cdk/asset-awscli-v1": {
|
|
@@ -8433,14 +8434,21 @@
|
|
|
8433
8434
|
"module": "constructs"
|
|
8434
8435
|
}
|
|
8435
8436
|
}
|
|
8437
|
+
},
|
|
8438
|
+
"lambda-failure-detector": {
|
|
8439
|
+
"targets": {
|
|
8440
|
+
"js": {
|
|
8441
|
+
"npm": "lambda-failure-detector"
|
|
8442
|
+
}
|
|
8443
|
+
}
|
|
8436
8444
|
}
|
|
8437
8445
|
},
|
|
8438
|
-
"description": "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
|
|
8446
|
+
"description": "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 in every enabled region of the account (or only in the regions given by targetRegions) 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.",
|
|
8439
8447
|
"docs": {
|
|
8440
8448
|
"stability": "stable"
|
|
8441
8449
|
},
|
|
8442
8450
|
"homepage": "https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler.git",
|
|
8443
|
-
"jsiiVersion": "6.0.
|
|
8451
|
+
"jsiiVersion": "6.0.20 (build 338bb97)",
|
|
8444
8452
|
"keywords": [
|
|
8445
8453
|
"aurora",
|
|
8446
8454
|
"aws",
|
|
@@ -8463,7 +8471,7 @@
|
|
|
8463
8471
|
},
|
|
8464
8472
|
"name": "rds-database-running-scheduler",
|
|
8465
8473
|
"readme": {
|
|
8466
|
-
"markdown": "# RDS Database Running Scheduler (CDK v2)\n\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/actions/workflows/build.yml)\n\n[](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.\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 waits until they reach the desired state or the per-resource wait limit.\n- **Configurable wait**: Set `resourceWait.intervalSeconds` and `resourceWait.maxSeconds` to control how often each resource is checked and how long the function waits before timing out. Defaults are 60 seconds and 1800 seconds.\n- **Optional Slack notifications**: Set `notification.slack.enable` to `SlackNotificationEnable.ENABLED` and provide `secretName` to post schedule progress and per-resource results to Slack via Secrets Manager. Leave `enable` unset (default `SlackNotificationEnable.DISABLED`), set it to `DISABLED`, or omit `notification.slack` to skip secret lookup, Slack API calls, and related IAM grants. When Slack is enabled, a timeout posts a message unless `notification.slack.notifyOnWaitTimeout` is `WaitTimeoutNotification.DISABLED`.\n- **Supported resources**: RDS DB instances and RDS Aurora clusters.\n\n## How it works\n\nEventBridge Scheduler runs a start cron and a stop cron. Each one invokes a durable Lambda function.\n\nThe function searches the deployment account for RDS DB instances and Aurora clusters that match `targetResource`. When both a cluster and its member instances match, only the cluster is controlled. Each remaining resource is started or stopped in the region taken from its ARN.\n\nThe function then checks that resource every `resourceWait.intervalSeconds` until it is available or stopped, or until `resourceWait.maxSeconds` elapses. When Slack is enabled, it posts progress and, by default, a message when the wait limit is exceeded.\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### pnpm\n\n```bash\npnpm 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 { RDSDatabaseRunningScheduler } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n});\n```\n\nThis uses the default schedules: start at 07:50 UTC and stop at 19:05 UTC, Monday–Friday. Slack notifications are off.\n\nWith Slack notifications and a custom schedule:\n\n```typescript\nimport { TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduler, SchedulingEnable, SlackNotificationEnable } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n notification: { slack: { enable: SlackNotificationEnable.ENABLED, secretName: 'example/slack/webhook' } },\n enableScheduling: SchedulingEnable.ENABLED,\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 scheduler props.\n\n```typescript\nimport { App, TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduleStack, SchedulingEnable, SlackNotificationEnable } from 'rds-database-running-scheduler';\n\nconst app = new App();\n\nnew RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n notification: { slack: { enable: SlackNotificationEnable.ENABLED, secretName: 'example/slack/webhook' } },\n enableScheduling: SchedulingEnable.ENABLED,\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\nWhen Slack is enabled, the 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| `notification` | `Notification` | No | Notification channels. Set `notification.slack.enable` to `SlackNotificationEnable.ENABLED` to send Slack messages. |\n| `resourceWait` | `ResourceWait` | No | Per-resource status-check interval and maximum wait. Default: 60-second interval, 1800-second maximum. |\n| `enableScheduling` | `SchedulingEnable` | No | Whether start and stop schedules are enabled. `ENABLED` or `DISABLED`. Default: `ENABLED`. |\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 | Required | Description |\n|-------|------|----------|-------------|\n| `timezone` | `TimeZone` | Yes | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |\n| `minute` | `string` | No | Cron minute (for example `'50'`). |\n| `hour` | `string` | No | Cron hour (for example `'7'`, `'19'`). |\n| `week` | `string` | No | Cron week day (for example `'MON-FRI'`). |\n\n### TargetResource\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `tagKey` | `string` | Yes | Tag key to filter RDS resources. |\n| `tagValues` | `string[]` | Yes | Tag values to match (resources with any of these values are targeted). |\n\n### Notification\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `slack` | `SlackNotification` | No | Slack settings. Omit, or set `enable` to `SlackNotificationEnable.DISABLED`, to disable Slack. |\n\n### SlackNotification\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `enable` | `SlackNotificationEnable` | No | Enable Slack notifications. `ENABLED` or `DISABLED`. Default: `DISABLED`. When `DISABLED`, secret lookup, Slack API calls, and IAM grants are skipped. |\n| `secretName` | `string` | No | Secrets Manager secret name containing Slack `token` and `channel`. Required when `enable` is `ENABLED`. |\n| `notifyOnWaitTimeout` | `WaitTimeoutNotification` | No | Post a Slack message when a resource exceeds `resourceWait.maxSeconds`. `ENABLED` or `DISABLED`. Applies only when `enable` is `ENABLED`. Default: `ENABLED`. |\n\n### ResourceWait\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `intervalSeconds` | `number` | No | Seconds between status checks. Positive integer. Default: `60`. |\n| `maxSeconds` | `number` | No | Maximum accumulated wait seconds for one resource. Positive integer, greater than or equal to `intervalSeconds`, and at most `6900`. Default: `1800`. |\n\n## API\n\nSee [API.md](./API.md).\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, and CloudWatch Logs; RDS describe/start/stop permissions for targeted resources. Start/stop IAM is scoped to DB instance and cluster ARNs in the account and to `aws:ResourceTag` matching `targetResource`. Resource Groups Tagging API access is required for resource discovery. Secrets Manager access is required only when Slack notifications are enabled.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n"
|
|
8474
|
+
"markdown": "# RDS Database Running Scheduler (CDK v2)\n\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://www.npmjs.com/package/rds-database-running-scheduler)\n[](https://github.com/gammarers-aws-cdk-constructs/rds-database-running-scheduler/actions/workflows/build.yml)\n\n[](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.\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- **Multi-region discovery**: Searches every region enabled for the account, one region at a time, for tagged RDS resources. Set `targetRegions` to search only the regions you list.\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- **Cross-region control**: Each resource is started and stopped in the region it lives in, even when that is not the stack's region.\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 waits until they reach the desired state or the per-resource wait limit.\n- **Configurable wait**: Set `resourceWait.intervalSeconds` and `resourceWait.maxSeconds` to control how often each resource is checked and how long the function waits before timing out. Defaults are 60 seconds and 1800 seconds.\n- **Optional Slack notifications**: Set `notification.slack.enable` to `SlackNotificationEnable.ENABLED` and provide `secretName` to post schedule progress and per-resource results to Slack via Secrets Manager. Leave `enable` unset (default `SlackNotificationEnable.DISABLED`), set it to `DISABLED`, or omit `notification.slack` to skip secret lookup, Slack API calls, and related IAM grants. When Slack is enabled, a timeout posts a message unless `notification.slack.notifyOnWaitTimeout` is `WaitTimeoutNotification.DISABLED`.\n- **Opt-in failure detection**: Set `failureDetection.enabled` to `true` to create CloudWatch alarms for the Lambda `Errors` and `Throttles` metrics and for the handler's failure logs (wait timeout, unexpected status, failed execution). Pass an existing SNS topic as `failureDetection.alarmTopic` to be notified. Nothing is created by default, and the construct never creates an SNS topic.\n- **Supported resources**: RDS DB instances and RDS Aurora clusters.\n\n## How it works\n\nEventBridge Scheduler runs a start cron and a stop cron. Each one invokes a durable Lambda function. A failed invocation is retried at most twice, and only while the original event is less than 2 hours old. That window matches the durable execution timeout and is not configurable via props today. On the default schedule it ends before the opposite cron, so a failed stop is not run again after the next start.\n\nThe function lists the regions enabled for the account and searches each one with the Resource Groups Tagging API for RDS DB instances and Aurora clusters that match `targetResource`. The Tagging API returns only the resources of the region it is called in, so each region is searched separately. When `targetRegions` is set, only those regions are searched. When both a cluster and its member instances match, only the cluster is controlled. Each remaining resource is started or stopped in the region taken from its ARN.\n\nThe function then checks that resource every `resourceWait.intervalSeconds` until it is available or stopped, or until `resourceWait.maxSeconds` elapses. A stop also waits through `storage-optimization`. A start that sees `storage-optimization` waits until the status is `stopped`, then starts the database. `configuring-iam-database-auth` and `configuring-log-exports` are waited on the same way. When Slack is enabled, it posts progress and, by default, a message when the wait limit is exceeded.\n\nSome cases change nothing. When no resource matches, the run ends without posting to Slack. A resource that is already in the target state (available for a start, stopped for a stop) gets no start or stop call, but Slack still receives its result message. A cluster that no longer exists is skipped without a failure and without a result message. Both schedules can also be created in the disabled state with `enableScheduling`.\n\nA resource that does not reach its target state within the wait limit, or reports a status that cannot be handled (for example `incompatible-restore`), fails the run. The other resources are still processed first, then the whole execution is marked as failed. The failure is also written to the log, which is what the opt-in failure detection alarms watch.\n\nThe Lambda log group keeps logs for three months. It is deleted only when its creation fails, and it is retained when the stack is deleted or the resource is replaced, so failures stay investigable.\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### pnpm\n\n```bash\npnpm add rds-database-running-scheduler\n```\n\n## Usage\n\n### Minimal deployable app\n\nUse the **Stack** `RDSDatabaseRunningScheduleStack` when you want a dedicated stack you can deploy as-is. Put this in your CDK app entry (for example `bin/app.ts`).\n\n```typescript\nimport { App } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduleStack } from 'rds-database-running-scheduler';\n\nconst app = new App();\n\nnew RDSDatabaseRunningScheduleStack(app, 'RDSDatabaseRunningScheduleStack', {\n env: {\n account: process.env.CDK_DEFAULT_ACCOUNT,\n region: process.env.CDK_DEFAULT_REGION,\n },\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n});\n\napp.synth();\n```\n\nThis uses the default schedules: start at 07:50 UTC and stop at 19:05 UTC, Monday–Friday. Slack notifications and failure detection are off. Every region enabled for the account is searched.\n\nDeploy checklist:\n\n1. Install this package and its peers (`aws-cdk-lib`, `constructs`, `lambda-failure-detector`) in your CDK app.\n2. Tag the RDS DB instances or Aurora clusters you want to control with the same `tagKey` and one of the `tagValues`.\n3. Only when you enable Slack, create the Secrets Manager secret first (see [Slack secret](#slack-secret)).\n4. From the CDK app: `npx cdk deploy RDSDatabaseRunningScheduleStack`\n\n### Construct\n\nUse the **Construct** `RDSDatabaseRunningScheduler` when adding the scheduler into an existing Stack or any CDK scope. It accepts the same scheduler props as the Stack.\n\n```typescript\nimport { RDSDatabaseRunningScheduler } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n});\n```\n\nTo search only some regions, list them in `targetRegions`:\n\n```typescript\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n targetRegions: ['ap-northeast-1', 'us-east-1'],\n});\n```\n\nTo be alerted when a run fails, enable failure detection and pass an SNS topic you already own:\n\n```typescript\nimport { Topic } from 'aws-cdk-lib/aws-sns';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n failureDetection: {\n enabled: true,\n alarmTopic: Topic.fromTopicArn(scope, 'AlarmTopic', 'arn:aws:sns:ap-northeast-1:123456789012:alarm-topic'),\n },\n});\n```\n\nWith Slack notifications and a custom schedule:\n\n```typescript\nimport { TimeZone } from 'aws-cdk-lib';\nimport { RDSDatabaseRunningScheduler, SchedulingEnable, SlackNotificationEnable } from 'rds-database-running-scheduler';\n\nnew RDSDatabaseRunningScheduler(scope, 'RDSDatabaseRunningScheduler', {\n targetResource: { tagKey: 'WorkHoursRunning', tagValues: ['YES'] },\n notification: { slack: { enable: SlackNotificationEnable.ENABLED, secretName: 'example/slack/webhook' } },\n enableScheduling: SchedulingEnable.ENABLED,\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\nThe Stack takes the same props, so the same options work with `RDSDatabaseRunningScheduleStack`.\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\n### Slack secret\n\nSlack is optional. Only when `notification.slack.enable` is `SlackNotificationEnable.ENABLED` do you need to create the secret in AWS Secrets Manager **before deploying**. Without it, no secret is read and no secret-related IAM is granted. When enabled, the construct grants the Lambda read access to that secret and attaches the AWS Parameters and Secrets Lambda Extension layer, so you do not add either yourself. The secret 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| `targetRegions` | `string[]` | No | Regions to search for tagged RDS resources. Each must be a region enabled for the account. Must not be empty, blank, or contain duplicates. Default: every region enabled for the account. |\n| `notification` | `Notification` | No | Notification channels. Set `notification.slack.enable` to `SlackNotificationEnable.ENABLED` to send Slack messages. |\n| `resourceWait` | `ResourceWait` | No | Per-resource status-check interval and maximum wait. Default: 60-second interval, 1800-second maximum. |\n| `enableScheduling` | `SchedulingEnable` | No | Whether start and stop schedules are enabled. `ENABLED` or `DISABLED`. Default: `ENABLED`. |\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| `failureDetection` | `LambdaFailureDetection` | No | Opt-in CloudWatch failure detection from [lambda-failure-detector](https://www.npmjs.com/package/lambda-failure-detector). Alarms are created only when `enabled` is `true`. `alarmTopic` is an optional existing SNS topic for every alarm. Default: no failure detection resources. |\n\n### Schedule\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `timezone` | `TimeZone` | Yes | CDK timezone constant (for example `TimeZone.ASIA_TOKYO`, `TimeZone.ETC_UTC`). |\n| `minute` | `string` | No | Cron minute (for example `'50'`). |\n| `hour` | `string` | No | Cron hour (for example `'7'`, `'19'`). |\n| `week` | `string` | No | Cron week day (for example `'MON-FRI'`). |\n\n### TargetResource\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `tagKey` | `string` | Yes | Tag key to filter RDS resources. |\n| `tagValues` | `string[]` | Yes | Tag values to match (resources with any of these values are targeted). |\n\n### Notification\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `slack` | `SlackNotification` | No | Slack settings. Omit, or set `enable` to `SlackNotificationEnable.DISABLED`, to disable Slack. |\n\n### SlackNotification\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `enable` | `SlackNotificationEnable` | No | Enable Slack notifications. `ENABLED` or `DISABLED`. Default: `DISABLED`. When `DISABLED`, secret lookup, Slack API calls, and IAM grants are skipped. |\n| `secretName` | `string` | No | Secrets Manager secret name containing Slack `token` and `channel`. Required when `enable` is `ENABLED`. |\n| `notifyOnWaitTimeout` | `WaitTimeoutNotification` | No | Post a Slack message when a resource exceeds `resourceWait.maxSeconds`. `ENABLED` or `DISABLED`. Applies only when `enable` is `ENABLED`. Default: `ENABLED`. |\n\n### ResourceWait\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `intervalSeconds` | `number` | No | Seconds between status checks. Positive integer. Default: `60`. |\n| `maxSeconds` | `number` | No | Maximum accumulated wait seconds for one resource. Positive integer, greater than or equal to `intervalSeconds`, and at most `6900`. Default: `1800`. |\n\n## API\n\nSee [API.md](./API.md).\n\n## Requirements\n\n- **Node.js**: >= 20.0.0\n- **AWS CDK**: ^2.232.0\n- **constructs**: ^10.5.1\n- **lambda-failure-detector**: ^0.2.1 (peer dependency, used only when `failureDetection.enabled` is `true`)\n- **AWS**: Account and region with permissions to create EventBridge Scheduler, Lambda, IAM, and CloudWatch Logs; RDS describe/start/stop permissions for targeted resources. Start/stop IAM is scoped to DB instance and cluster ARNs in the account and to `aws:ResourceTag` matching `targetResource`. Resource Groups Tagging API access (`tag:GetResources`) and `ec2:DescribeRegions` are required for resource discovery. Secrets Manager access is required only when Slack notifications are enabled.\n\n## Notes\n\n- **Least privilege**: Discovery and status checks (`tag:GetResources`, `ec2:DescribeRegions`, `rds:DescribeDBInstances`, `rds:DescribeDBClusters`) do not support resource-level permissions, so they use `*`. Start and stop are limited to DB instance and cluster ARNs in your account and to resources whose `aws:ResourceTag/<tagKey>` matches `targetResource`. The region part of those ARNs is `*` because tagged resources may live outside the stack region.\n- **Safe to run again**: A start on an available resource and a stop on a stopped resource make no RDS call, so a retried or repeated run does not repeat a finished operation.\n- **Retries**: Failed invocations are retried at most twice within 2 hours, which is not configurable via props today. A run that fails because a resource timed out or reported an unexpected status is a failed invocation too.\n\n## Troubleshooting\n\nStart with the Lambda log group (`/aws/lambda/<function name>`). It keeps logs for three months and is retained when the stack is deleted.\n\nWhen nothing seems to happen, check these in order:\n\n1. The schedules were not created with `enableScheduling: SchedulingEnable.DISABLED`.\n2. The resources carry the exact `tagKey` and one of the `tagValues`.\n3. The resources are in a searched region: every enabled region by default, or only `targetRegions` when it is set.\n4. The resource is not a cluster that no longer exists, which is skipped silently.\n\nWhen Slack messages are missing, confirm the secret exists, contains `token` and `channel`, and that `notification.slack.enable` is `ENABLED`. A secret that cannot be read fails the run.\n\nWhen `failureDetection.enabled` is `true`, these alarms are created. Each one counts ERROR logs that start with the marker of the same name, in the `RDSDatabaseRunningScheduler` metric namespace:\n\n| Alarm / marker | Meaning |\n|----------------|---------|\n| `ResourceWaitTimedOut` | A resource did not reach its target state within `resourceWait.maxSeconds`. |\n| `ResourceStatusUnexpected` | A resource reported a status that cannot be handled, for example `incompatible-restore`. |\n| `ScheduleExecutionFailed` | The whole execution failed for any reason, including the two above. It also fires for failures before any resource is processed, such as an invalid `targetRegions`. |\n\nThe Lambda `Errors` and `Throttles` alarms cover failures of the invocation itself. A durable execution that fails inside the handler does not always raise `Errors`, so rely on `ScheduleExecutionFailed` for those.\n\n## License\n\nThis project is licensed under the (Apache-2.0) License.\n"
|
|
8467
8475
|
},
|
|
8468
8476
|
"repository": {
|
|
8469
8477
|
"type": "git",
|
|
@@ -8488,7 +8496,7 @@
|
|
|
8488
8496
|
"kind": "interface",
|
|
8489
8497
|
"locationInModule": {
|
|
8490
8498
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8491
|
-
"line":
|
|
8499
|
+
"line": 111
|
|
8492
8500
|
},
|
|
8493
8501
|
"name": "Notification",
|
|
8494
8502
|
"properties": [
|
|
@@ -8502,7 +8510,7 @@
|
|
|
8502
8510
|
"immutable": true,
|
|
8503
8511
|
"locationInModule": {
|
|
8504
8512
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8505
|
-
"line":
|
|
8513
|
+
"line": 116
|
|
8506
8514
|
},
|
|
8507
8515
|
"name": "slack",
|
|
8508
8516
|
"optional": true,
|
|
@@ -8519,7 +8527,7 @@
|
|
|
8519
8527
|
"docs": {
|
|
8520
8528
|
"remarks": "Delegates resource discovery, cluster-priority deduplication, start/stop\nexecution, per-resource wait limits, and optional Slack notifications to\n{@link RDSDatabaseRunningScheduler}.",
|
|
8521
8529
|
"stability": "stable",
|
|
8522
|
-
"summary": "CDK stack that provisions scheduled start/stop control for tagged RDS resources in the deployment account
|
|
8530
|
+
"summary": "CDK stack that provisions scheduled start/stop control for tagged RDS resources in the enabled regions of the deployment account, or only in `targetRegions`."
|
|
8523
8531
|
},
|
|
8524
8532
|
"fqn": "rds-database-running-scheduler.RDSDatabaseRunningScheduleStack",
|
|
8525
8533
|
"initializer": {
|
|
@@ -8594,7 +8602,7 @@
|
|
|
8594
8602
|
"assembly": "rds-database-running-scheduler",
|
|
8595
8603
|
"base": "constructs.Construct",
|
|
8596
8604
|
"docs": {
|
|
8597
|
-
"remarks": "The Lambda
|
|
8605
|
+
"remarks": "The Lambda lists the regions enabled for the account, searches each one with\nthe Resource Groups Tagging API (or only the regions in `targetRegions`),\ndeduplicates Aurora cluster member instances when the parent cluster is also\ntagged, and controls each remaining resource using the region encoded in its\nARN. Each resource is checked on a configurable interval\nuntil it reaches a stable state or the per-resource wait limit. A failed\nschedule invocation is retried at most twice, and only while the original\nevent is less than 2 hours old, so a stop failure is not replayed after the\nnext start. When Slack is enabled, the Lambda posts progress and results to\nSlack, and can post a timeout message when the wait limit is exceeded.\nOtherwise Secrets Manager lookup, Slack API calls, and related IAM grants\nare skipped. When `failureDetection.enabled` is `true`, CloudWatch alarms\nwatch the Lambda and the handler's failure logs.",
|
|
8598
8606
|
"stability": "stable",
|
|
8599
8607
|
"summary": "CDK construct that provisions a durable Lambda workflow and EventBridge schedules to start/stop tagged RDS databases and clusters."
|
|
8600
8608
|
},
|
|
@@ -8606,7 +8614,7 @@
|
|
|
8606
8614
|
},
|
|
8607
8615
|
"locationInModule": {
|
|
8608
8616
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8609
|
-
"line":
|
|
8617
|
+
"line": 402
|
|
8610
8618
|
},
|
|
8611
8619
|
"parameters": [
|
|
8612
8620
|
{
|
|
@@ -8641,9 +8649,28 @@
|
|
|
8641
8649
|
"kind": "class",
|
|
8642
8650
|
"locationInModule": {
|
|
8643
8651
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8644
|
-
"line":
|
|
8652
|
+
"line": 388
|
|
8645
8653
|
},
|
|
8646
8654
|
"name": "RDSDatabaseRunningScheduler",
|
|
8655
|
+
"properties": [
|
|
8656
|
+
{
|
|
8657
|
+
"docs": {
|
|
8658
|
+
"remarks": "Undefined unless `failureDetection.enabled` is `true`.",
|
|
8659
|
+
"stability": "stable",
|
|
8660
|
+
"summary": "Failure detection alarms of the scheduler Lambda."
|
|
8661
|
+
},
|
|
8662
|
+
"immutable": true,
|
|
8663
|
+
"locationInModule": {
|
|
8664
|
+
"filename": "src/rds-database-running-scheduler.ts",
|
|
8665
|
+
"line": 393
|
|
8666
|
+
},
|
|
8667
|
+
"name": "failureDetector",
|
|
8668
|
+
"optional": true,
|
|
8669
|
+
"type": {
|
|
8670
|
+
"fqn": "lambda-failure-detector.LambdaFailureDetector"
|
|
8671
|
+
}
|
|
8672
|
+
}
|
|
8673
|
+
],
|
|
8647
8674
|
"symbolId": "src/rds-database-running-scheduler:RDSDatabaseRunningScheduler"
|
|
8648
8675
|
},
|
|
8649
8676
|
"rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps": {
|
|
@@ -8657,7 +8684,7 @@
|
|
|
8657
8684
|
"kind": "interface",
|
|
8658
8685
|
"locationInModule": {
|
|
8659
8686
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8660
|
-
"line":
|
|
8687
|
+
"line": 141
|
|
8661
8688
|
},
|
|
8662
8689
|
"name": "RDSDatabaseRunningSchedulerProps",
|
|
8663
8690
|
"properties": [
|
|
@@ -8670,7 +8697,7 @@
|
|
|
8670
8697
|
"immutable": true,
|
|
8671
8698
|
"locationInModule": {
|
|
8672
8699
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8673
|
-
"line":
|
|
8700
|
+
"line": 143
|
|
8674
8701
|
},
|
|
8675
8702
|
"name": "targetResource",
|
|
8676
8703
|
"type": {
|
|
@@ -8687,7 +8714,7 @@
|
|
|
8687
8714
|
"immutable": true,
|
|
8688
8715
|
"locationInModule": {
|
|
8689
8716
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8690
|
-
"line":
|
|
8717
|
+
"line": 155
|
|
8691
8718
|
},
|
|
8692
8719
|
"name": "enableScheduling",
|
|
8693
8720
|
"optional": true,
|
|
@@ -8695,6 +8722,25 @@
|
|
|
8695
8722
|
"fqn": "rds-database-running-scheduler.SchedulingEnable"
|
|
8696
8723
|
}
|
|
8697
8724
|
},
|
|
8725
|
+
{
|
|
8726
|
+
"abstract": true,
|
|
8727
|
+
"docs": {
|
|
8728
|
+
"default": "- no failure detection resources are created",
|
|
8729
|
+
"remarks": "Alarms are created only when `failureDetection.enabled` is `true`. They cover the\nLambda `Errors` and `Throttles` metrics and three log-based signals from the handler:\na resource wait timeout, an unexpected resource status, and any failed execution.\nA durable execution that fails inside the handler does not always raise the Lambda\n`Errors` metric, so the log-based alarms are the reliable signal for those failures.\nSet `alarmTopic` to attach an existing SNS topic to every alarm. The construct never\ncreates an SNS topic, and without `alarmTopic` the alarms have no notification actions.",
|
|
8730
|
+
"stability": "stable",
|
|
8731
|
+
"summary": "Opt-in CloudWatch failure detection for the scheduler Lambda."
|
|
8732
|
+
},
|
|
8733
|
+
"immutable": true,
|
|
8734
|
+
"locationInModule": {
|
|
8735
|
+
"filename": "src/rds-database-running-scheduler.ts",
|
|
8736
|
+
"line": 183
|
|
8737
|
+
},
|
|
8738
|
+
"name": "failureDetection",
|
|
8739
|
+
"optional": true,
|
|
8740
|
+
"type": {
|
|
8741
|
+
"fqn": "lambda-failure-detector.LambdaFailureDetection"
|
|
8742
|
+
}
|
|
8743
|
+
},
|
|
8698
8744
|
{
|
|
8699
8745
|
"abstract": true,
|
|
8700
8746
|
"docs": {
|
|
@@ -8705,7 +8751,7 @@
|
|
|
8705
8751
|
"immutable": true,
|
|
8706
8752
|
"locationInModule": {
|
|
8707
8753
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8708
|
-
"line":
|
|
8754
|
+
"line": 161
|
|
8709
8755
|
},
|
|
8710
8756
|
"name": "notification",
|
|
8711
8757
|
"optional": true,
|
|
@@ -8723,7 +8769,7 @@
|
|
|
8723
8769
|
"immutable": true,
|
|
8724
8770
|
"locationInModule": {
|
|
8725
8771
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8726
|
-
"line":
|
|
8772
|
+
"line": 166
|
|
8727
8773
|
},
|
|
8728
8774
|
"name": "resourceWait",
|
|
8729
8775
|
"optional": true,
|
|
@@ -8740,7 +8786,7 @@
|
|
|
8740
8786
|
"immutable": true,
|
|
8741
8787
|
"locationInModule": {
|
|
8742
8788
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8743
|
-
"line":
|
|
8789
|
+
"line": 170
|
|
8744
8790
|
},
|
|
8745
8791
|
"name": "startSchedule",
|
|
8746
8792
|
"optional": true,
|
|
@@ -8757,13 +8803,37 @@
|
|
|
8757
8803
|
"immutable": true,
|
|
8758
8804
|
"locationInModule": {
|
|
8759
8805
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8760
|
-
"line":
|
|
8806
|
+
"line": 168
|
|
8761
8807
|
},
|
|
8762
8808
|
"name": "stopSchedule",
|
|
8763
8809
|
"optional": true,
|
|
8764
8810
|
"type": {
|
|
8765
8811
|
"fqn": "rds-database-running-scheduler.Schedule"
|
|
8766
8812
|
}
|
|
8813
|
+
},
|
|
8814
|
+
{
|
|
8815
|
+
"abstract": true,
|
|
8816
|
+
"docs": {
|
|
8817
|
+
"default": "- every region enabled for the account",
|
|
8818
|
+
"remarks": "Each name must be a region enabled for the account. When specified, the array\nmust not be empty and must not contain blank or duplicate names.",
|
|
8819
|
+
"stability": "stable",
|
|
8820
|
+
"summary": "Regions searched for tagged RDS instances and clusters."
|
|
8821
|
+
},
|
|
8822
|
+
"immutable": true,
|
|
8823
|
+
"locationInModule": {
|
|
8824
|
+
"filename": "src/rds-database-running-scheduler.ts",
|
|
8825
|
+
"line": 150
|
|
8826
|
+
},
|
|
8827
|
+
"name": "targetRegions",
|
|
8828
|
+
"optional": true,
|
|
8829
|
+
"type": {
|
|
8830
|
+
"collection": {
|
|
8831
|
+
"elementtype": {
|
|
8832
|
+
"primitive": "string"
|
|
8833
|
+
},
|
|
8834
|
+
"kind": "array"
|
|
8835
|
+
}
|
|
8836
|
+
}
|
|
8767
8837
|
}
|
|
8768
8838
|
],
|
|
8769
8839
|
"symbolId": "src/rds-database-running-scheduler:RDSDatabaseRunningSchedulerProps"
|
|
@@ -8779,7 +8849,7 @@
|
|
|
8779
8849
|
"kind": "interface",
|
|
8780
8850
|
"locationInModule": {
|
|
8781
8851
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8782
|
-
"line":
|
|
8852
|
+
"line": 122
|
|
8783
8853
|
},
|
|
8784
8854
|
"name": "ResourceWait",
|
|
8785
8855
|
"properties": [
|
|
@@ -8794,7 +8864,7 @@
|
|
|
8794
8864
|
"immutable": true,
|
|
8795
8865
|
"locationInModule": {
|
|
8796
8866
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8797
|
-
"line":
|
|
8867
|
+
"line": 128
|
|
8798
8868
|
},
|
|
8799
8869
|
"name": "intervalSeconds",
|
|
8800
8870
|
"optional": true,
|
|
@@ -8813,7 +8883,7 @@
|
|
|
8813
8883
|
"immutable": true,
|
|
8814
8884
|
"locationInModule": {
|
|
8815
8885
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8816
|
-
"line":
|
|
8886
|
+
"line": 135
|
|
8817
8887
|
},
|
|
8818
8888
|
"name": "maxSeconds",
|
|
8819
8889
|
"optional": true,
|
|
@@ -8835,7 +8905,7 @@
|
|
|
8835
8905
|
"kind": "interface",
|
|
8836
8906
|
"locationInModule": {
|
|
8837
8907
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8838
|
-
"line":
|
|
8908
|
+
"line": 60
|
|
8839
8909
|
},
|
|
8840
8910
|
"name": "Schedule",
|
|
8841
8911
|
"properties": [
|
|
@@ -8848,7 +8918,7 @@
|
|
|
8848
8918
|
"immutable": true,
|
|
8849
8919
|
"locationInModule": {
|
|
8850
8920
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8851
|
-
"line":
|
|
8921
|
+
"line": 62
|
|
8852
8922
|
},
|
|
8853
8923
|
"name": "timezone",
|
|
8854
8924
|
"type": {
|
|
@@ -8864,7 +8934,7 @@
|
|
|
8864
8934
|
"immutable": true,
|
|
8865
8935
|
"locationInModule": {
|
|
8866
8936
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8867
|
-
"line":
|
|
8937
|
+
"line": 66
|
|
8868
8938
|
},
|
|
8869
8939
|
"name": "hour",
|
|
8870
8940
|
"optional": true,
|
|
@@ -8881,7 +8951,7 @@
|
|
|
8881
8951
|
"immutable": true,
|
|
8882
8952
|
"locationInModule": {
|
|
8883
8953
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8884
|
-
"line":
|
|
8954
|
+
"line": 64
|
|
8885
8955
|
},
|
|
8886
8956
|
"name": "minute",
|
|
8887
8957
|
"optional": true,
|
|
@@ -8898,7 +8968,7 @@
|
|
|
8898
8968
|
"immutable": true,
|
|
8899
8969
|
"locationInModule": {
|
|
8900
8970
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8901
|
-
"line":
|
|
8971
|
+
"line": 68
|
|
8902
8972
|
},
|
|
8903
8973
|
"name": "week",
|
|
8904
8974
|
"optional": true,
|
|
@@ -8919,7 +8989,7 @@
|
|
|
8919
8989
|
"kind": "enum",
|
|
8920
8990
|
"locationInModule": {
|
|
8921
8991
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8922
|
-
"line":
|
|
8992
|
+
"line": 40
|
|
8923
8993
|
},
|
|
8924
8994
|
"members": [
|
|
8925
8995
|
{
|
|
@@ -8952,7 +9022,7 @@
|
|
|
8952
9022
|
"kind": "interface",
|
|
8953
9023
|
"locationInModule": {
|
|
8954
9024
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8955
|
-
"line":
|
|
9025
|
+
"line": 85
|
|
8956
9026
|
},
|
|
8957
9027
|
"name": "SlackNotification",
|
|
8958
9028
|
"properties": [
|
|
@@ -8967,7 +9037,7 @@
|
|
|
8967
9037
|
"immutable": true,
|
|
8968
9038
|
"locationInModule": {
|
|
8969
9039
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8970
|
-
"line":
|
|
9040
|
+
"line": 92
|
|
8971
9041
|
},
|
|
8972
9042
|
"name": "enable",
|
|
8973
9043
|
"optional": true,
|
|
@@ -8985,7 +9055,7 @@
|
|
|
8985
9055
|
"immutable": true,
|
|
8986
9056
|
"locationInModule": {
|
|
8987
9057
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
8988
|
-
"line":
|
|
9058
|
+
"line": 103
|
|
8989
9059
|
},
|
|
8990
9060
|
"name": "notifyOnWaitTimeout",
|
|
8991
9061
|
"optional": true,
|
|
@@ -9003,7 +9073,7 @@
|
|
|
9003
9073
|
"immutable": true,
|
|
9004
9074
|
"locationInModule": {
|
|
9005
9075
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9006
|
-
"line":
|
|
9076
|
+
"line": 97
|
|
9007
9077
|
},
|
|
9008
9078
|
"name": "secretName",
|
|
9009
9079
|
"optional": true,
|
|
@@ -9024,7 +9094,7 @@
|
|
|
9024
9094
|
"kind": "enum",
|
|
9025
9095
|
"locationInModule": {
|
|
9026
9096
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9027
|
-
"line":
|
|
9097
|
+
"line": 30
|
|
9028
9098
|
},
|
|
9029
9099
|
"members": [
|
|
9030
9100
|
{
|
|
@@ -9056,7 +9126,7 @@
|
|
|
9056
9126
|
"kind": "interface",
|
|
9057
9127
|
"locationInModule": {
|
|
9058
9128
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9059
|
-
"line":
|
|
9129
|
+
"line": 74
|
|
9060
9130
|
},
|
|
9061
9131
|
"name": "TargetResource",
|
|
9062
9132
|
"properties": [
|
|
@@ -9069,7 +9139,7 @@
|
|
|
9069
9139
|
"immutable": true,
|
|
9070
9140
|
"locationInModule": {
|
|
9071
9141
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9072
|
-
"line":
|
|
9142
|
+
"line": 76
|
|
9073
9143
|
},
|
|
9074
9144
|
"name": "tagKey",
|
|
9075
9145
|
"type": {
|
|
@@ -9085,7 +9155,7 @@
|
|
|
9085
9155
|
"immutable": true,
|
|
9086
9156
|
"locationInModule": {
|
|
9087
9157
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9088
|
-
"line":
|
|
9158
|
+
"line": 78
|
|
9089
9159
|
},
|
|
9090
9160
|
"name": "tagValues",
|
|
9091
9161
|
"type": {
|
|
@@ -9110,7 +9180,7 @@
|
|
|
9110
9180
|
"kind": "enum",
|
|
9111
9181
|
"locationInModule": {
|
|
9112
9182
|
"filename": "src/rds-database-running-scheduler.ts",
|
|
9113
|
-
"line":
|
|
9183
|
+
"line": 50
|
|
9114
9184
|
},
|
|
9115
9185
|
"members": [
|
|
9116
9186
|
{
|
|
@@ -9132,6 +9202,6 @@
|
|
|
9132
9202
|
"symbolId": "src/rds-database-running-scheduler:WaitTimeoutNotification"
|
|
9133
9203
|
}
|
|
9134
9204
|
},
|
|
9135
|
-
"version": "0.
|
|
9136
|
-
"fingerprint": "
|
|
9205
|
+
"version": "0.6.1",
|
|
9206
|
+
"fingerprint": "FYTI0uo3btfYJ035XI6BJUKZ27+gGV+oOlq31LYcM/Y="
|
|
9137
9207
|
}
|
package/API.md
CHANGED
|
@@ -6,14 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
CDK construct that provisions a durable Lambda workflow and EventBridge schedules to start/stop tagged RDS databases and clusters.
|
|
8
8
|
|
|
9
|
-
The Lambda
|
|
10
|
-
Tagging API
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
The Lambda lists the regions enabled for the account, searches each one with
|
|
10
|
+
the Resource Groups Tagging API (or only the regions in `targetRegions`),
|
|
11
|
+
deduplicates Aurora cluster member instances when the parent cluster is also
|
|
12
|
+
tagged, and controls each remaining resource using the region encoded in its
|
|
13
|
+
ARN. Each resource is checked on a configurable interval
|
|
14
|
+
until it reaches a stable state or the per-resource wait limit. A failed
|
|
15
|
+
schedule invocation is retried at most twice, and only while the original
|
|
16
|
+
event is less than 2 hours old, so a stop failure is not replayed after the
|
|
17
|
+
next start. When Slack is enabled, the Lambda posts progress and results to
|
|
18
|
+
Slack, and can post a timeout message when the wait limit is exceeded.
|
|
19
|
+
Otherwise Secrets Manager lookup, Slack API calls, and related IAM grants
|
|
20
|
+
are skipped. When `failureDetection.enabled` is `true`, CloudWatch alarms
|
|
21
|
+
watch the Lambda and the handler's failure logs.
|
|
17
22
|
|
|
18
23
|
#### Initializers <a name="Initializers" id="rds-database-running-scheduler.RDSDatabaseRunningScheduler.Initializer"></a>
|
|
19
24
|
|
|
@@ -138,6 +143,7 @@ Any object.
|
|
|
138
143
|
| **Name** | **Type** | **Description** |
|
|
139
144
|
| --- | --- | --- |
|
|
140
145
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
|
|
146
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduler.property.failureDetector">failureDetector</a></code> | <code>lambda-failure-detector.LambdaFailureDetector</code> | Failure detection alarms of the scheduler Lambda. |
|
|
141
147
|
|
|
142
148
|
---
|
|
143
149
|
|
|
@@ -153,10 +159,24 @@ The tree node.
|
|
|
153
159
|
|
|
154
160
|
---
|
|
155
161
|
|
|
162
|
+
##### `failureDetector`<sup>Optional</sup> <a name="failureDetector" id="rds-database-running-scheduler.RDSDatabaseRunningScheduler.property.failureDetector"></a>
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
public readonly failureDetector: LambdaFailureDetector;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- *Type:* lambda-failure-detector.LambdaFailureDetector
|
|
169
|
+
|
|
170
|
+
Failure detection alarms of the scheduler Lambda.
|
|
171
|
+
|
|
172
|
+
Undefined unless `failureDetection.enabled` is `true`.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
156
176
|
|
|
157
177
|
### RDSDatabaseRunningScheduleStack <a name="RDSDatabaseRunningScheduleStack" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStack"></a>
|
|
158
178
|
|
|
159
|
-
CDK stack that provisions scheduled start/stop control for tagged RDS resources in the deployment account
|
|
179
|
+
CDK stack that provisions scheduled start/stop control for tagged RDS resources in the enabled regions of the deployment account, or only in `targetRegions`.
|
|
160
180
|
|
|
161
181
|
Delegates resource discovery, cluster-priority deduplication, start/stop
|
|
162
182
|
execution, per-resource wait limits, and optional Slack notifications to
|
|
@@ -1172,10 +1192,12 @@ const rDSDatabaseRunningSchedulerProps: RDSDatabaseRunningSchedulerProps = { ...
|
|
|
1172
1192
|
| --- | --- | --- |
|
|
1173
1193
|
| <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. |
|
|
1174
1194
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.enableScheduling">enableScheduling</a></code> | <code><a href="#rds-database-running-scheduler.SchedulingEnable">SchedulingEnable</a></code> | Enables or disables both start and stop schedules. |
|
|
1195
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.failureDetection">failureDetection</a></code> | <code>lambda-failure-detector.LambdaFailureDetection</code> | Opt-in CloudWatch failure detection for the scheduler Lambda. |
|
|
1175
1196
|
| <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. |
|
|
1176
1197
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.resourceWait">resourceWait</a></code> | <code><a href="#rds-database-running-scheduler.ResourceWait">ResourceWait</a></code> | Optional per-resource wait settings. |
|
|
1177
1198
|
| <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. |
|
|
1178
1199
|
| <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. |
|
|
1200
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.targetRegions">targetRegions</a></code> | <code>string[]</code> | Regions searched for tagged RDS instances and clusters. |
|
|
1179
1201
|
|
|
1180
1202
|
---
|
|
1181
1203
|
|
|
@@ -1204,6 +1226,27 @@ Enables or disables both start and stop schedules.
|
|
|
1204
1226
|
|
|
1205
1227
|
---
|
|
1206
1228
|
|
|
1229
|
+
##### `failureDetection`<sup>Optional</sup> <a name="failureDetection" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.failureDetection"></a>
|
|
1230
|
+
|
|
1231
|
+
```typescript
|
|
1232
|
+
public readonly failureDetection: LambdaFailureDetection;
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1235
|
+
- *Type:* lambda-failure-detector.LambdaFailureDetection
|
|
1236
|
+
- *Default:* no failure detection resources are created
|
|
1237
|
+
|
|
1238
|
+
Opt-in CloudWatch failure detection for the scheduler Lambda.
|
|
1239
|
+
|
|
1240
|
+
Alarms are created only when `failureDetection.enabled` is `true`. They cover the
|
|
1241
|
+
Lambda `Errors` and `Throttles` metrics and three log-based signals from the handler:
|
|
1242
|
+
a resource wait timeout, an unexpected resource status, and any failed execution.
|
|
1243
|
+
A durable execution that fails inside the handler does not always raise the Lambda
|
|
1244
|
+
`Errors` metric, so the log-based alarms are the reliable signal for those failures.
|
|
1245
|
+
Set `alarmTopic` to attach an existing SNS topic to every alarm. The construct never
|
|
1246
|
+
creates an SNS topic, and without `alarmTopic` the alarms have no notification actions.
|
|
1247
|
+
|
|
1248
|
+
---
|
|
1249
|
+
|
|
1207
1250
|
##### `notification`<sup>Optional</sup> <a name="notification" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.notification"></a>
|
|
1208
1251
|
|
|
1209
1252
|
```typescript
|
|
@@ -1257,6 +1300,22 @@ Optional override for stop schedule cron configuration.
|
|
|
1257
1300
|
|
|
1258
1301
|
---
|
|
1259
1302
|
|
|
1303
|
+
##### `targetRegions`<sup>Optional</sup> <a name="targetRegions" id="rds-database-running-scheduler.RDSDatabaseRunningSchedulerProps.property.targetRegions"></a>
|
|
1304
|
+
|
|
1305
|
+
```typescript
|
|
1306
|
+
public readonly targetRegions: string[];
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
- *Type:* string[]
|
|
1310
|
+
- *Default:* every region enabled for the account
|
|
1311
|
+
|
|
1312
|
+
Regions searched for tagged RDS instances and clusters.
|
|
1313
|
+
|
|
1314
|
+
Each name must be a region enabled for the account. When specified, the array
|
|
1315
|
+
must not be empty and must not contain blank or duplicate names.
|
|
1316
|
+
|
|
1317
|
+
---
|
|
1318
|
+
|
|
1260
1319
|
### RDSDatabaseRunningScheduleStackProps <a name="RDSDatabaseRunningScheduleStackProps" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps"></a>
|
|
1261
1320
|
|
|
1262
1321
|
Properties for the RDS database running schedule stack.
|
|
@@ -1278,10 +1337,12 @@ const rDSDatabaseRunningScheduleStackProps: RDSDatabaseRunningScheduleStackProps
|
|
|
1278
1337
|
| --- | --- | --- |
|
|
1279
1338
|
| <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 to select RDS instances and clusters. |
|
|
1280
1339
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.enableScheduling">enableScheduling</a></code> | <code><a href="#rds-database-running-scheduler.SchedulingEnable">SchedulingEnable</a></code> | Enables or disables both start and stop schedules. |
|
|
1340
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.failureDetection">failureDetection</a></code> | <code>lambda-failure-detector.LambdaFailureDetection</code> | Opt-in CloudWatch failure detection for the scheduler Lambda. |
|
|
1281
1341
|
| <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. |
|
|
1282
1342
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.resourceWait">resourceWait</a></code> | <code><a href="#rds-database-running-scheduler.ResourceWait">ResourceWait</a></code> | Optional per-resource wait settings. |
|
|
1283
1343
|
| <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 override for start schedule cron configuration. |
|
|
1284
1344
|
| <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 override for stop schedule cron configuration. |
|
|
1345
|
+
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.targetRegions">targetRegions</a></code> | <code>string[]</code> | Regions searched for tagged RDS instances and clusters. |
|
|
1285
1346
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.analyticsReporting">analyticsReporting</a></code> | <code>boolean</code> | Include runtime versioning information in this Stack. |
|
|
1286
1347
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.crossRegionReferences">crossRegionReferences</a></code> | <code>boolean</code> | Enable this flag to allow native cross region stack references. |
|
|
1287
1348
|
| <code><a href="#rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.description">description</a></code> | <code>string</code> | A description of the stack. |
|
|
@@ -1322,6 +1383,27 @@ Enables or disables both start and stop schedules.
|
|
|
1322
1383
|
|
|
1323
1384
|
---
|
|
1324
1385
|
|
|
1386
|
+
##### `failureDetection`<sup>Optional</sup> <a name="failureDetection" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.failureDetection"></a>
|
|
1387
|
+
|
|
1388
|
+
```typescript
|
|
1389
|
+
public readonly failureDetection: LambdaFailureDetection;
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
- *Type:* lambda-failure-detector.LambdaFailureDetection
|
|
1393
|
+
- *Default:* no failure detection resources are created
|
|
1394
|
+
|
|
1395
|
+
Opt-in CloudWatch failure detection for the scheduler Lambda.
|
|
1396
|
+
|
|
1397
|
+
Alarms are created only when `failureDetection.enabled` is `true`. They cover the
|
|
1398
|
+
Lambda `Errors` and `Throttles` metrics and three log-based signals from the handler:
|
|
1399
|
+
a resource wait timeout, an unexpected resource status, and any failed execution.
|
|
1400
|
+
A durable execution that fails inside the handler does not always raise the Lambda
|
|
1401
|
+
`Errors` metric, so the log-based alarms are the reliable signal for those failures.
|
|
1402
|
+
Set `alarmTopic` to attach an existing SNS topic to every alarm. The construct never
|
|
1403
|
+
creates an SNS topic, and without `alarmTopic` the alarms have no notification actions.
|
|
1404
|
+
|
|
1405
|
+
---
|
|
1406
|
+
|
|
1325
1407
|
##### `notification`<sup>Optional</sup> <a name="notification" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.notification"></a>
|
|
1326
1408
|
|
|
1327
1409
|
```typescript
|
|
@@ -1375,6 +1457,22 @@ Optional override for stop schedule cron configuration.
|
|
|
1375
1457
|
|
|
1376
1458
|
---
|
|
1377
1459
|
|
|
1460
|
+
##### `targetRegions`<sup>Optional</sup> <a name="targetRegions" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.targetRegions"></a>
|
|
1461
|
+
|
|
1462
|
+
```typescript
|
|
1463
|
+
public readonly targetRegions: string[];
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
- *Type:* string[]
|
|
1467
|
+
- *Default:* every region enabled for the account
|
|
1468
|
+
|
|
1469
|
+
Regions searched for tagged RDS instances and clusters.
|
|
1470
|
+
|
|
1471
|
+
Each name must be a region enabled for the account. When specified, the array
|
|
1472
|
+
must not be empty and must not contain blank or duplicate names.
|
|
1473
|
+
|
|
1474
|
+
---
|
|
1475
|
+
|
|
1378
1476
|
##### `analyticsReporting`<sup>Optional</sup> <a name="analyticsReporting" id="rds-database-running-scheduler.RDSDatabaseRunningScheduleStackProps.property.analyticsReporting"></a>
|
|
1379
1477
|
|
|
1380
1478
|
```typescript
|