Skip to content

RDS Database Insights Advanced using CDK

0

Hi,

does anybody have an example of how to enable "Advanced" database insights using cdk? I can do this manually however since we CDK our workload it would be great to do this programmatically. There are a few examples floating around to do this through customer resources however they failed and cause the whole deployment to rollback.

My understanding is that since this is fairly these properties are not available in the RDS packages/modules.

Thank you, Anton

asked 2 years ago1.8K views

1 Answer
0

While there isn't a direct CDK construct available for enabling Advanced Database Insights for RDS at the moment, you can still achieve this programmatically using CDK with a combination of existing constructs and properties.

To enable Advanced Database Insights, you need to ensure that Performance Insights is enabled and set to a retention period of at least 465 days. Here's a general approach you can take:

  1. When creating your RDS instance or cluster using CDK, make sure to enable Performance Insights.

  2. Set the Performance Insights retention period to at least 465 days.

  3. Enable the Advanced mode of Database Insights.

Here's a conceptual example of how you might structure this in CDK (note that the exact syntax may vary depending on your CDK version and the specific RDS engine you're using):

import * as rds from 'aws-cdk-lib/aws-rds';

// ... other imports and stack setup ...

const cluster = new rds.DatabaseCluster(this, 'MyDBCluster', {
  engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_02_0 }),
  instanceProps: {
    instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
    performanceInsightRetention: rds.PerformanceInsightRetention.LONG_TERM, // This sets it to 731 days
  },
  // ... other configuration options ...
});

// Enable Advanced Database Insights
cluster.addPropertyOverride('DatabaseInsightsMode', 'advanced');

In this example, we're creating an Aurora MySQL cluster, enabling Performance Insights with long-term retention (731 days), and then using the addPropertyOverride method to set the DatabaseInsightsMode to 'advanced'.

Please note that this is a conceptual example and may need to be adjusted based on your specific CDK version, RDS engine, and other requirements. Also, ensure that you have the necessary permissions in your execution role to modify these settings.

Remember that enabling Advanced Database Insights may incur additional costs, so be sure to review the pricing details for your specific use case.
Sources
Turning on the Advanced mode of Database Insights for Amazon Aurora - Amazon Aurora
Considerations for Database Insights for Amazon Aurora - Amazon Aurora
AWS CDK – Resources

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.