-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-rds: Cannot add a region to Aurora Global Database #29880
Comments
According the doc here:
You mentioned:
It's still unclear for me how to provision that from CFN's perspective. Can you share the doc link for this description you mentioned above to help us clarify? |
Here is information from CFN (doc) around specifying MasterUserPassword
There is a CFN example on this page for setting up a GlobalDatabase. You would notice that there is not |
Hi Team, Is there any update on this? |
Hi This doesn't seem to be a CDK bug and we need to look into this issue and report to relevant team. Are you able to provide your code snippet for Step
|
Hi Sure, Please see below. const auroraCluster = new rds.DatabaseCluster(this, "AuroraCluster", {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
credentials: rds.Credentials.fromSecret(secret),
defaultDatabaseName: "stocks",
writer: rds.ClusterInstance.provisioned('writer', {
enablePerformanceInsights: true,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE),
}),
storageEncrypted: true,
vpc: vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
},
securityGroups: [dbsg],
})
for (const az in vpc.availabilityZones) {
const azLetter = vpc.availabilityZones[az].slice(-1);
const cfnDBInstance = new rds.CfnDBInstance(this, `AuroraInstance-${az}`, {
dbClusterIdentifier: auroraCluster.clusterIdentifier,
dbInstanceIdentifier: `${azLetter}`,
engine: 'aurora-mysql',
dbInstanceClass: 'db.r6g.large',
publiclyAccessible: false,
enablePerformanceInsights: true,
availabilityZone: vpc.availabilityZones[az]
})
cfnDBInstance.node.addDependency(auroraCluster)
} Step 2 - Creating a Global Cluster using CfnGlobalCluster const cfnGlobalCluster = new rds.CfnGlobalCluster(this, 'AuroraGlobalCluster', {
deletionProtection: false,
globalClusterIdentifier: `${props.auroraglobalcluster}`,
sourceDbClusterIdentifier: auroraCluster.clusterIdentifier
}) |
Hi Team, Is there any update on this? |
Hi If I deploy like this: export class DummyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
// step 1 - Create a standard Aurora DB Cluster using DatabaseCluster
const auroraCluster = new rds.DatabaseCluster(this, "AuroraCluster", {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
// credentials: rds.Credentials.fromSecret(secret),
defaultDatabaseName: "stocks",
writer: rds.ClusterInstance.provisioned('writer', {
enablePerformanceInsights: true,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE),
}),
storageEncrypted: true,
vpc: vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
},
// securityGroups: [dbsg],
})
for (const az in vpc.availabilityZones) {
const azLetter = vpc.availabilityZones[az].slice(-1);
const cfnDBInstance = new rds.CfnDBInstance(this, `AuroraInstance-${az}`, {
dbClusterIdentifier: auroraCluster.clusterIdentifier,
dbInstanceIdentifier: `${azLetter}`,
engine: 'aurora-mysql',
dbInstanceClass: 'db.r6g.large',
publiclyAccessible: false,
enablePerformanceInsights: true,
availabilityZone: vpc.availabilityZones[az]
})
cfnDBInstance.node.addDependency(auroraCluster)
}
// step 2 - Create a Global Database using CfnGlobalCluster and add source DB Cluster as the one created in step one.
const cfnGlobalCluster = new rds.CfnGlobalCluster(this, 'AuroraGlobalCluster', {
deletionProtection: false,
globalClusterIdentifier: 'dummy-global-cluster',
sourceDbClusterIdentifier: auroraCluster.clusterIdentifier
})
// step 3 - Create a secondary DB Cluster using CfnDBCluster
const cfnDBCluster = new rds.CfnDBCluster(this, 'AuroraCluster2', {
globalClusterIdentifier: 'dummy-global-cluster',
dbClusterParameterGroupName: 'default.aurora-mysql8.0',
enableGlobalWriteForwarding: true,
availabilityZones: vpc.availabilityZones,
// dbSubnetGroupName: dbSubnetGroup.dbSubnetGroupName,
engine: 'aurora-mysql',
engineVersion: '8.0.mysql_aurora.3.04.0',
// kmsKeyId: 'alias/aws/rds'
})
}
} It would fail at step 3 with the error message:
Obviously, you cannot create an Aurora DB cluster as a read replica of another Aurora DB cluster within the same AWS region. Amazon RDS does not support creating read replicas of Aurora clusters in the same region. [1] To work it around, you need to separate them into 2 stacks in different regions: stack.ts export class PrimaryStack extends Stack {
readonly globalClusterIdentifier: string;
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
this.globalClusterIdentifier = 'dummy-global-cluster'
// step 1 - Create a standard Aurora DB Cluster using DatabaseCluster
const auroraCluster = new rds.DatabaseCluster(this, "AuroraCluster", {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
// credentials: rds.Credentials.fromSecret(secret),
defaultDatabaseName: "stocks",
writer: rds.ClusterInstance.provisioned('writer', {
enablePerformanceInsights: true,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R6G, ec2.InstanceSize.LARGE),
}),
storageEncrypted: true,
vpc: vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
},
// securityGroups: [dbsg],
})
for (const az in vpc.availabilityZones.slice(0, 3)) {
const azLetter = vpc.availabilityZones[az].slice(-1);
const cfnDBInstance = new rds.CfnDBInstance(this, `AuroraInstance-${az}`, {
dbClusterIdentifier: auroraCluster.clusterIdentifier,
dbInstanceIdentifier: `${azLetter}`,
engine: 'aurora-mysql',
dbInstanceClass: 'db.r6g.large',
publiclyAccessible: false,
enablePerformanceInsights: true,
availabilityZone: vpc.availabilityZones[az]
})
cfnDBInstance.node.addDependency(auroraCluster)
}
// step 2 - Create a Global Database using CfnGlobalCluster and add source DB Cluster as the one created in step one.
const cfnGlobalCluster = new rds.CfnGlobalCluster(this, 'AuroraGlobalCluster', {
deletionProtection: false,
globalClusterIdentifier: this.globalClusterIdentifier,
sourceDbClusterIdentifier: auroraCluster.clusterIdentifier
})
}
}
export interface ReplicaStackProps extends StackProps {
readonly globalClusterIdentifier: string;
}
export class ReplicaStack extends Stack {
constructor(scope: Construct, id: string, props: ReplicaStackProps) {
super(scope, id, props);
const globalClusterIdentifier = props.globalClusterIdentifier
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
// step 3 - Create a secondary DB Cluster using CfnDBCluster
const subnetGroup = new rds.SubnetGroup(this, 'SubnetGroup', {
description: 'Subnet group for Aurora cluster',
vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
onePerAz: true,
// select first 3 AZs from the list
availabilityZones: vpc.availabilityZones.slice(0,3),
},
});
const cfnDBCluster = new rds.CfnDBCluster(this, 'AuroraCluster2', {
globalClusterIdentifier: globalClusterIdentifier,
dbClusterParameterGroupName: 'default.aurora-mysql8.0',
enableGlobalWriteForwarding: true,
availabilityZones: vpc.availabilityZones.slice(0,3),
dbSubnetGroupName: subnetGroup.subnetGroupName,
engine: 'aurora-mysql',
engineVersion: '8.0.mysql_aurora.3.04.0',
kmsKeyId: 'alias/aws/rds',
})
for (const az in vpc.availabilityZones.slice(0, 3)) {
new rds.CfnDBInstance(this, `AuroraInstance-${az}`, {
dbClusterIdentifier: cfnDBCluster.ref,
engine: 'aurora-mysql',
dbInstanceClass: 'db.r6g.large',
dbSubnetGroupName: subnetGroup.subnetGroupName,
publiclyAccessible: false,
availabilityZone: vpc.availabilityZones[az],
})
}
}
} app.ts // create the primary stack in us-east-1
const primaryStack = new PrimaryStack(app, 'primary-stack', { env: { region: 'us-east-1', account: process.env.CDK_DEFAULT_ACCOUNT } });
// create the replica stack in us-west-2
new ReplicaStack(app, 'replica-stack', {
env: { region: 'us-west-2', account: process.env.CDK_DEFAULT_ACCOUNT },
globalClusterIdentifier: primaryStack.globalClusterIdentifier,
}); It deploys for me with no error. Let me know if it works for you. |
Thanks, yes I am aware we need to pass in different regions to implement this. In your example I don't see any db instances being added to replica in secondary region. And I think that is the issue. Can you try and add DB instances to that secondary replica? |
Yes I would see this error when adding instances in the replica cluster using globalClusterIdentifier: We need to verify
As long as we figure out how to do that with CFN, we would know how to do this using CDK. I am raising this internally with relevant teams for clarifying. internal tracking: P139881819 |
Hi @sadiqinz I have updated my sample code above and it deploys now. it looks like this in the RDS console: Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Thanks for all the help @pahud |
|
Great help from the team to find a resolution for this issue |
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one. |
Describe the bug
When creating an Global Aurora Database, you cannot add another Region to it.
We get an error message
Resource handler returned message: "Invalid master password
Expected Behavior
You should be able to add additional Regions to Aurora Global Database.
Once a Global Database is created, you can create a secondary Cluster and add
globalClusterIdentifier
. Even though there is not L2 construct for adding a cluster to Global Database, L1 constructCfnDBCluster
should allow you to specifyglobalClusterIdentifier
.Current Behavior
When you try and create the secondary cluster using
CfnDBCluster
construct, following error is thrown by CloudFormationResource handler returned message: "Invalid master password
. Even though based on the documentation, if you specifyglobalClusterIdentifier
, you can't then give master password as it uses the one from source DB cluster.Reproduction Steps
DatabaseCluster
CfnGlobalCluster
and add source DB Cluster as the one created in step one.CfnDBCluster
as followingThis would produce an error message by CloudFormation.
Possible Solution
Either fix the bug in
CfnDBCluster
construct to support GlobalDatabases or create add GlobalDatabase support in L2 constructDatabaseCluster
Additional Information/Context
No response
CDK CLI Version
2.131.0
Framework Version
No response
Node.js Version
v18.16.0
OS
macOS 14.3.1
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: