Skip to content

Commit

Permalink
feat(rds): support performance insights for cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
go-to-k committed Sep 10, 2024
1 parent 6348717 commit 4e69dda
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,27 @@ interface DatabaseClusterBaseProps {
* @default - false
*/
readonly enableDataApi?: boolean;

/**
* Whether to enable Performance Insights for the DB instance.
*
* @default - false, unless `performanceInsightRetention` or `performanceInsightEncryptionKey` is set.
*/
readonly enablePerformanceInsights?: boolean;

/**
* The amount of time, in days, to retain Performance Insights data.
*
* @default 7
*/
readonly performanceInsightRetention?: PerformanceInsightRetention;

/**
* The AWS KMS key for encryption of Performance Insights data.
*
* @default - default master key
*/
readonly performanceInsightEncryptionKey?: kms.IKey;
}

/**
Expand Down Expand Up @@ -690,6 +711,12 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
});
}

const enablePerformanceInsights = props.enablePerformanceInsights
|| props.performanceInsightRetention !== undefined || props.performanceInsightEncryptionKey !== undefined;
if (enablePerformanceInsights && props.enablePerformanceInsights === false) {
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set');
}

this.newCfnProps = {
// Basic
engine: props.engine.engineType,
Expand Down Expand Up @@ -730,6 +757,11 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
copyTagsToSnapshot: props.copyTagsToSnapshot ?? true,
domain: this.domainId,
domainIamRoleName: this.domainRole?.roleName,
performanceInsightsEnabled: enablePerformanceInsights || props.enablePerformanceInsights, // fall back to undefined if not set
performanceInsightsKmsKeyId: props.performanceInsightEncryptionKey?.keyArn,
performanceInsightsRetentionPeriod: enablePerformanceInsights
? (props.performanceInsightRetention || PerformanceInsightRetention.DEFAULT)
: undefined,
};
}

Expand Down

0 comments on commit 4e69dda

Please sign in to comment.