[英]How can we create cross region RDS read replica using AWS cloud formation template?
I have easily found a way to create RDS read replica in same region using AWS cloud formation, but:我很容易找到了一种使用 AWS 云形成在同一区域创建 RDS 只读副本的方法,但是:
1. Can we create the same in different region using CF template? 1.我们可以使用CF模板在不同的区域创建相同的吗?
2. Also can we promote it to primary using CF template? 2. 也可以使用CF模板将其提升为primary吗?
1) Yes, you can create a RDS read replica in different region using CloudFormation. 1) 是的,您可以使用 CloudFormation 在不同区域创建 RDS 只读副本。 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
.在目标区域(要在其中创建只读副本)创建 CloudFormation 模板,并将源数据库实例 arn (位于源区域)作为
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. 2) 目前,我认为使用 cloudformation 推广只读副本是不可能的。 But you can achieve this using a lambda function.
但是您可以使用 lambda 函数来实现这一点。
promote-read-replica
api in the sdk of your choice.promote-read-replica
API。 Create a sns topic in the source region,and add it as a trigger for the lambda function.在源区域创建一个sns主题,并将其添加为lambda函数的触发器。 Dont forget to add invoke permission for SNS to the Lambda using the SNSTopicArn .
不要忘记使用 SNSTopicArn 将 SNS 的调用权限添加到 Lambda 。
In source RDS console, Go to Event Subscription and select the sns topic arn you created above as the target arn to receive events.在源 RDS 控制台中,转到事件订阅并选择您在上面创建的sns 主题 arn作为接收事件的目标 arn。 Under event categories, select
deletion, failure
for you source database.在事件类别下,为您的源数据库选择
deletion, failure
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.