Skip to content

Commit 056320b

Browse files
committed
chore: improve error messages and documentation for Database Insights configuration
1 parent 9ed3e5e commit 056320b

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

packages/aws-cdk-lib/aws-rds/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,9 +1383,7 @@ The standard mode of Database Insights is enabled by default for Aurora database
13831383

13841384
You can enhance the monitoring of your Aurora databases by enabling the advanced mode of Database Insights.
13851385

1386-
See [AWS docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Database-Insights.html) for more information about Database Insights.
1387-
1388-
The following example shows enabling the advanced mode of Database Insights for a clustered database.
1386+
To control Database Insights mode, use the `databaseInsightsMode` property:
13891387

13901388
```ts
13911389
declare const vpc: ec2.Vpc;
@@ -1401,11 +1399,9 @@ new rds.DatabaseCluster(this, 'Database', {
14011399
});
14021400
```
14031401

1404-
Note that settings regarding Database Insights are only possible at the cluster level.
1405-
1406-
### Supported Engines
1402+
Note: Database Insights are only supported for Amazon Aurora MySQL and Amazon Aurora PostgreSQL clusters.
14071403

1408-
Database Insights supports Amazon Aurora MySQL and Amazon Aurora PostgreSQL.
1404+
> Visit [CloudWatch Database Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Database-Insights.html) for more details.
14091405
14101406
## Enhanced Monitoring
14111407

packages/aws-cdk-lib/aws-rds/lib/cluster.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ interface DatabaseClusterBaseProps {
428428
/**
429429
* The amount of time, in days, to retain Performance Insights data.
430430
*
431-
* @default - 7(PerformanceInsightRetention.DEFAULT) if `enablePerformanceInsights` is set,
432-
* 465(PerformanceInsightRetention.MONTHS_15) if DatabaseInsightsMode.ADVANCED is set for `databaseInsightsMode`.
431+
* @default - 7 days if `enablePerformanceInsights` is set. 465 days (15 months) if `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED.
433432
*/
434433
readonly performanceInsightRetention?: PerformanceInsightRetention;
435434

@@ -443,7 +442,7 @@ interface DatabaseClusterBaseProps {
443442
/**
444443
* The database insights mode.
445444
*
446-
* @default - DatabaseInsightsMode.STANDARD if Amazon Aurora engine is used, otherwise not set.
445+
* @default - DatabaseInsightsMode.STANDARD when performance insights are enabled and Amazon Aurora engine is used, otherwise not set.
447446
*/
448447
readonly databaseInsightsMode?: DatabaseInsightsMode;
449448

@@ -556,8 +555,6 @@ export enum DatabaseInsightsMode {
556555

557556
/**
558557
* Advanced mode.
559-
*
560-
* In advanced mode, Performance Insights must be enabled.
561558
*/
562559
ADVANCED = 'advanced',
563560
}
@@ -865,13 +862,13 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
865862
|| props.performanceInsightEncryptionKey !== undefined
866863
|| props.databaseInsightsMode === DatabaseInsightsMode.ADVANCED;
867864
if (enablePerformanceInsights && props.enablePerformanceInsights === false) {
868-
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to `DatabaseInsightsMode.ADVANCED`');
865+
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to \'${DatabaseInsightsMode.ADVANCED}\'');
869866
}
870867
if (props.databaseInsightsMode === DatabaseInsightsMode.ADVANCED
871868
&& props.performanceInsightRetention
872869
&& props.performanceInsightRetention !== PerformanceInsightRetention.MONTHS_15
873870
) {
874-
throw new Error('`performanceInsightRetention` must be set to PerformanceInsightRetention.MONTHS_15 when `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED');
871+
throw new Error('`performanceInsightRetention` must be set to \'${PerformanceInsightRetention.MONTHS_15}\' when `databaseInsightsMode` is set to \'${DatabaseInsightsMode.ADVANCED}\'');
875872
}
876873

877874
// Database Insights is not supported for non-Aurora engines

packages/aws-cdk-lib/aws-rds/test/cluster.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,7 @@ describe('cluster', () => {
25982598
enablePerformanceInsights: false,
25992599
databaseInsightsMode: DatabaseInsightsMode.ADVANCED,
26002600
});
2601-
}).toThrow(/`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to `DatabaseInsightsMode.ADVANCED`/);
2601+
}).toThrow(/`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set, or `databaseInsightsMode` was set to '\${DatabaseInsightsMode.ADVANCED}'/);
26022602
});
26032603

26042604
test('throw if the advanced mode of database insights is set and any retention other than MONTHS_15 is set for performanceInsightRetention', () => {
@@ -2614,7 +2614,7 @@ describe('cluster', () => {
26142614
performanceInsightRetention: PerformanceInsightRetention.LONG_TERM,
26152615
databaseInsightsMode: DatabaseInsightsMode.ADVANCED,
26162616
});
2617-
}).toThrow(/`performanceInsightRetention` must be set to PerformanceInsightRetention.MONTHS_15 when `databaseInsightsMode` is set to DatabaseInsightsMode.ADVANCED/);
2617+
}).toThrow(/`performanceInsightRetention` must be set to '\${PerformanceInsightRetention.MONTHS_15}' when `databaseInsightsMode` is set to '\${DatabaseInsightsMode.ADVANCED}'/);
26182618
});
26192619
});
26202620

0 commit comments

Comments
 (0)