Skip to content
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

fix(rds): pass the ARN of master instead of its ID in DatabaseInstanceReadReplica #5702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,8 @@ export class DatabaseInstanceReadReplica extends DatabaseInstanceNew implements

const instance = new CfnDBInstance(this, 'Resource', {
...this.newCfnProps,
sourceDbInstanceIdentifier: props.sourceDatabaseInstance.instanceIdentifier,
// this must be ARN, not ID, because of https://github.com/terraform-providers/terraform-provider-aws/issues/528#issuecomment-391169012
sourceDbInstanceIdentifier: props.sourceDatabaseInstance.instanceArn,
kmsKeyId: props.kmsKey && props.kmsKey.keyArn,
storageEncrypted: props.kmsKey ? true : props.storageEncrypted,
});
Expand Down
18 changes: 15 additions & 3 deletions packages/@aws-cdk/aws-rds/test/test.instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export = {
test.done();
},

'create a read replica'(test: Test) {
'create a read replica in the same region - with the subnet group name'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
Expand All @@ -323,8 +323,20 @@ export = {
// THEN
expect(stack).to(haveResource('AWS::RDS::DBInstance', {
SourceDBInstanceIdentifier: {
Ref: 'InstanceC1063A87'
}
"Fn::Join": ["", [
"arn:",
{ Ref: "AWS::Partition" },
":rds:",
{ Ref: "AWS::Region" },
":",
{ Ref: "AWS::AccountId" },
":db:",
{ Ref: "InstanceC1063A87" },
]],
},
DBSubnetGroupName: {
Ref: 'ReadReplicaSubnetGroup680C605C',
},
}));

test.done();
Expand Down