Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rds): support performance insights configuration at cluster level #31385

Merged
merged 18 commits into from
Oct 15, 2024
Merged
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
go-to-k marked this conversation as resolved.
Show resolved Hide resolved
performanceInsightsKmsKeyId: props.performanceInsightEncryptionKey?.keyArn,
performanceInsightsRetentionPeriod: enablePerformanceInsights
? (props.performanceInsightRetention || PerformanceInsightRetention.DEFAULT)
: undefined,
};
}

Expand Down
Loading