Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/aws-cdk-lib/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,10 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData
this.enableIamAuthentication = props.iamAuthentication;

const enablePerformanceInsights = props.enablePerformanceInsights
|| props.performanceInsightRetention !== undefined
|| props.performanceInsightEncryptionKey !== undefined
|| props.databaseInsightsMode === DatabaseInsightsMode.ADVANCED;
?? (props.performanceInsightRetention !== undefined
|| props.performanceInsightEncryptionKey !== undefined
|| props.databaseInsightsMode === DatabaseInsightsMode.ADVANCED
|| undefined);

if (props.domain) {
this.domainId = props.domain;
Expand Down Expand Up @@ -1018,7 +1019,7 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData
deletionProtection: defaultDeletionProtection(props.deletionProtection, props.removalPolicy),
enableCloudwatchLogsExports: this.cloudwatchLogsExports,
enableIamDatabaseAuthentication: Lazy.any({ produce: () => this.enableIamAuthentication }),
enablePerformanceInsights: enablePerformanceInsights || props.enablePerformanceInsights, // fall back to undefined if not set,
enablePerformanceInsights: enablePerformanceInsights,
iops,
monitoringInterval: props.monitoringInterval?.toSeconds(),
monitoringRoleArn: monitoringRole?.roleRef.roleArn,
Expand Down
13 changes: 13 additions & 0 deletions packages/aws-cdk-lib/aws-rds/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,19 @@ describe('instance', () => {
});
});

test('explicitly disabling performance insights is respected', () => {
new rds.DatabaseInstanceFromSnapshot(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_19 }),
vpc,
snapshotIdentifier: 'my-snapshot',
enablePerformanceInsights: false,
});

Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', {
EnablePerformanceInsights: false,
});
});

test('throws if performance insights fields are set but performance insights is disabled', () => {
expect(() => {
new rds.DatabaseInstance(stack, 'Instance', {
Expand Down
Loading