Skip to content
Open
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
33 changes: 33 additions & 0 deletions cdk/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,15 @@ export class CacclRdsDb extends CacclDbBase {
* e.g. '8.0.mysql_aurora.3.02.0' -> '8.0'
*/
const majorVersion = engineVersion.substring(0, 3);

const auroraMysqlEngineVersion = rds.DatabaseClusterEngine.auroraMysql({
version: rds.AuroraMysqlEngineVersion.of(engineVersion, majorVersion),
});

const auroraMysqlEngineVersionV3 = rds.DatabaseClusterEngine.auroraMysql({
version: rds.AuroraMysqlEngineVersion.of(engineVersion, '8.0'),
});

// performance insights for rds mysql not supported on t3 instances
const enablePerformanceInsights = !instanceType.startsWith('t3');

Expand All @@ -398,6 +403,18 @@ export class CacclRdsDb extends CacclDbBase {
},
);

const clusterParameterGroupV3 = new rds.ParameterGroup(
this,
'ClusterParameterGroupV3',
{
engine: auroraMysqlEngineVersionV3,
description: `RDS parameter group for ${Stack.of(this).stackName}`,
parameters: {
lower_case_table_names: '1',
},
},
);

this.instanceParameterGroupParams.slow_query_log = '1';
this.instanceParameterGroupParams.log_output = 'TABLE';
this.instanceParameterGroupParams.long_query_time = '3';
Expand All @@ -416,6 +433,18 @@ export class CacclRdsDb extends CacclDbBase {
},
);

const instanceParameterGroupV3 = new rds.ParameterGroup(
this,
'InstanceParameterGroupV3',
{
engine: auroraMysqlEngineVersionV3,
description: `RDS instance parameter group for ${
Stack.of(this).stackName
}`,
parameters: this.instanceParameterGroupParams,
},
);

this.dbCluster = new rds.DatabaseCluster(this, 'RdsDbCluster', {
engine: auroraMysqlEngineVersion,
clusterIdentifier: `${Stack.of(this).stackName}-db-cluster`,
Expand Down Expand Up @@ -445,6 +474,10 @@ export class CacclRdsDb extends CacclDbBase {
// this needs to happen after the parameter group has been associated with the cluster
clusterParameterGroup.applyRemovalPolicy(this.etcRemovalPolicy);
instanceParameterGroup.applyRemovalPolicy(this.etcRemovalPolicy);
clusterParameterGroupV3.bindToCluster({});
clusterParameterGroupV3.applyRemovalPolicy(this.etcRemovalPolicy);
instanceParameterGroupV3.bindToInstance({});
instanceParameterGroupV3.applyRemovalPolicy(this.etcRemovalPolicy);

// for rds/mysql we do NOT include the port as part of the host value
this.host = this.dbCluster.clusterEndpoint.hostname;
Expand Down