aws-rds - Impossible to define a DatabaseInstanceReadReplica from a DatabaseCluster
Aurora Cluster Replication
I'm trying to create a cross-region read replica from an Aurora Cluster.
How can I provide a sourceDatabaseInstance from a DatabaseCluster instance?
https://docs.aws.amazon.com/cdk/api/latest/docs/aws-rds-readme.html
const cluster = new DatabaseCluster(this, 'database-cluster', props);
const readReplica = new DatabaseInstanceReadReplica(this, 'read-replica', {
sourceDatabaseInstance: ???
})
Environment
- CDK CLI Version: 1.22.0
- Module Version: 1.15.0
- OS: OSX Mojave
- Language: TypeScript
Other information
Ideally, the cluster object could provide us with its replica database instances.
Alternatively, we could compute the instance Arn from cluster.instanceIdentifiers and change the signature of the DatabaseInstanceReadReplicaProps from readonly sourceDatabaseInstance: IDatabaseInstance; to readonly sourceDatabaseInstanceArn: string;
Thanks,
DatabaseInstanceReadReplica - as the name suggests is intended to create a database instance as a replioca of another DatabaseInstance. It leverages RDS' support to create a read replica.
From what I see in the documentation, RDS does not support creating a DB instance replica from a DB cluster.
Is there something else you're looking for?
Closing this since no response for a while now. Please re-open when you have more information here.
@nija-at thats interesting as I am reading this:
Two Aurora MySQL DB clusters in different AWS Regions, by creating an Aurora Read Replica of an Aurora MySQL DB cluster in a different AWS Region
and also CfnDBCluster exposes sourceDbClusterIdentifier
edit: the current solution btw (if needed) is cast to CfnDBCluster and add the source that way as seen here (kotlin example):
val addSourceRds = myRdsCluster.node.defaultChild as CfnDBCluster?
addSourceRds!!.sourceDbClusterIdentifier = RdsStack!!.masterCluster!!.clusterIdentifier
edit: the current solution btw (if needed) is cast to CfnDBCluster and add the source that way as seen here (kotlin example):
val addSourceRds = myRdsCluster.node.defaultChild as CfnDBCluster? addSourceRds!!.sourceDbClusterIdentifier = RdsStack!!.masterCluster!!.clusterIdentifier
Anybody have a TypeScript example of how to create a cross-region read replica from an Aurora cluster?
This gives an error: Property AllocatedStorage cannot be empty. in CDK version 1.111.0.
const cluster = new DatabaseCluster(this, 'database-cluster', props);
const readReplica = new DatabaseInstanceReadReplica(this, 'read-replica', {
sourceDatabaseInstance: cluster
})
Hey @AustinMaddox ,
the types in your code don't match - DatabaseInstanceReadReplica needs an IDatabaseInstance passed through the sourceDatabaseInstance property, which DatabaseCluster is not (it's a Cluster after all, not an Instance 🙂).
Thanks, Adam
Thanks @skinny85 I do realize that fact. I guess the real problem is there isn't a construct that exists for what I'm trying to do. I imagine it would be called DatabaseClusterReadReplica rather than DatabaseInstanceReadReplica if it did exist.
Any alternatives or workaround to create a read replica of a cluster (or member instance writer/reader of a cluster)?
I'm not sure. Do you know how would you set it up using CloudFormation by any chance?