- Newest
- Most votes
- Most comments
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:
-
When creating your RDS instance or cluster using CDK, make sure to enable Performance Insights.
-
Set the Performance Insights retention period to at least 465 days.
-
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
