const dbCluster = new rds.DatabaseCluster(this, 'Database', {
parameterGroup,
engine: engine,
credentials: rdsCredentials,
cloudwatchLogsExports:['slowquery','general','error','audit'],
backup: backupProps,
instances:instances,
storageEncrypted:true,
removalPolicy: cdk.RemovalPolicy.DESTROY,
clusterIdentifier: dbInfos['cluster'], //clusterIdentifier,
defaultDatabaseName :dbInfos['database'], //defaultDatabaseName,
instanceProps: {
instanceType: instanceType,
vpcSubnets:props.vpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE_ISOLATED }),
vpc:props!.vpc,
securityGroups:[dbSecurityGroup],
},
subnetGroup:subnetGroup
});
new rds.DatabaseInstanceReadReplica(this, 'ReadReplica', {
sourceDatabaseInstance: dbCluster, // error
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc,
});
There comes the error at sourceDatabaseInstance: dbCluster
Type 'DatabaseCluster' is missing the following properties from type 'IDatabaseInstance': instanceIdentifier, instanceArn, dbInstanceEndpointAddress, dbInstanceEndpointPort, and 6 more.ts(2740)
instance.d.ts(676, 14): The expected type comes from property 'sourceDatabaseInstance' which is declared here on type 'DatabaseInstanceReadReplicaProps'
Now I am trying to add read replicas to Amazon Aurora:
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseInstanceReadReplica.html
DatabaseInstanceReadReplica accepts the sourceDatabaseInstance as IDatabaseInstance
However Aurora has cluster but not instance.
So what should I set here?