2

I have easily found a way to create RDS read replica in same region using AWS cloud formation, but:
1. Can we create the same in different region using CF template?
2. Also can we promote it to primary using CF template?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Prashant Goel
  • 141
  • 1
  • 7
  • This does not seem to be the case with Aurora Engine. I believe we can create a read replica through the AWS CLI, Management Console for Aurora, but I don't see support for it in CF templates, could someone correct me if I am wrong. – Vikash Raja Samuel Selvin Apr 26 '18 at 19:17

1 Answers1

6

1) Yes, you can create a RDS read replica in different region using CloudFormation. Create a CloudFormation template in target region (where you want to create the read-replica) and give the source database instance arn (which is in source region) as input for SourceDBInstanceIdentifier.

Resources:
  # Create Data DB
  myReplciaDB:
    Type: AWS::RDS::DBInstance
    Properties:
      DBInstanceIdentifier: "read-replica"
      PubliclyAccessible: false
      SourceDBInstanceIdentifier: "arn:aws:rds:us-east-1:XXXXXX:db:source-database"
      StorageType: gp2

Check this link for more info.

2) Currently, I dont think it is possible to promote a read replica using cloudformation. But you can achieve this using a lambda function.

  • Create a lambda function in the target region, which uses the promote-read-replica api in the sdk of your choice.
  • Create a sns topic in the source region,and add it as a trigger for the lambda function. Dont forget to add invoke permission for SNS to the Lambda using the SNSTopicArn.

  • In source RDS console, Go to Event Subscription and select the sns topic arn you created above as the target arn to receive events. Under event categories, select deletion, failure for you source database.

Madhukar Mohanraju
  • 2,793
  • 11
  • 28