Home > Software design >  Set parameter group for the default database of cdk generated
Set parameter group for the default database of cdk generated

Time:04-01

I am making RDS by cdk

with default database.

const dbCluster = new rds.DatabaseCluster(this, 'Database', {
  engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
  credentials: rdsCredentials,
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  clusterIdentifier: dbInfos['cluster'], //clusterIdentifier,
  defaultDatabaseName :dbInfos['database'], //defaultDatabaseName,
  instanceProps: {
    instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
    vpcSubnets: {
      subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
    },
    vpc,
    securityGroups:[mySecurityGroup],
  },
});

I want to set the character code(utf8mb4) for this default database.

I think I should use the parameter group for this though ,,,

where can I set the parameter group?


I make the parameterGroup like this.

const parameterGroup = new rds.ParameterGroup(this, 'RdsParameterGroup', {
  engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
  parameters: {
    time_zone: 'Asia/Tokyo',
    character_set_client: 'utf8mb4',
    character_set_connection: 'utf8mb4',
    character_set_database: 'utf8mb4',
    character_set_results: 'utf8mb4',
    character_set_server: 'utf8mb4',
    collation_connection: 'utf8mb4_bin',
    slow_query_log: '1',
    long_query_time: '1',
    log_output: 'FILE',
  },
})

and adding

const dbCluster = new rds.DatabaseCluster(this, 'Database', {
  parameterGroup,
.
.
.

CodePudding user response:

DatabaseCluster has a parameterGroup argument. Have you looked at it ? The same can be updated using the ParameterGroup or the L1 version of it with "CfnDBParameterGroup"

  • Related