简体   繁体   中英

Set parameter group for the default database of cdk generated

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,
.
.
.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM