Reputation: 151
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?
Upvotes: 3
Views: 5889
Reputation: 2863
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.
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.
Upvotes: 7