gpt4 book ai didi

amazon-web-services - 如何使用 cloudformation 模板创建 Amazon RDS aurora 主节点和只读副本集群

转载 作者:行者123 更新时间:2023-12-03 07:48:24 25 4
gpt4 key购买 nike

使用 cloudformation 模板创建 Amazon RDS 主节点和只读副本集群。

最佳答案

我们可以使用下面的cloudformation模板创建Amazon Aurora RDS。只是我们需要在创建堆栈时传递参数。

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Aurora Db Stack",
"Parameters": {
"EnvironmentName": {
"Description": "The string that will be prefixed to each instance name",
"Type": "String",
"MinLength": "3",
"MaxLength": "6",
"AllowedPattern": "[a-z0-9]*",
"ConstraintDescription": "Environment names must be 3-6 characters and contain only a-z and 0-9."
},
"DbUsername": {
"Description": "App Db Username",
"Type": "String",
"MinLength": "5",
"MaxLength": "15",
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
},
"DbPassword": {
"Description": "App Db Password",
"NoEcho": "true",
"Type": "String",
"MinLength": "15",
"MaxLength": "41",
"AllowedPattern": "[a-zA-Z0-9]*",
"ConstraintDescription": "App Db Password must be 15-41 characters and contain only alpha numeric characters."
},
"DbType": {
"Description": "App Db server RDS instance type",
"Type": "String",
"Default": "db.r3.large",
"AllowedValues": [
"db.r3.large",
"db.r3.xlarge",
"db.r3.2xlarge",
"db.r3.4xlarge",
"db.r3.8xlarge"
],
"ConstraintDescription": "must be a valid RDS instance type."
},
"DBIdentifierNameMaster": {
"Description": "The string that will be prefixed to each instance name",
"Type": "String",
"MinLength": "3",
"MaxLength": "10",
"AllowedPattern": "[a-z0-9]*",
"ConstraintDescription": "Identifier names must be 3-6 characters and contain only a-z and 0-9."
},
"DBIdentifierNameReplica": {
"Description": "The string that will be prefixed to each instance name",
"Type": "String",
"MinLength": "3",
"MaxLength": "10",
"AllowedPattern": "[a-z0-9]*",
"ConstraintDescription": "Identifier names must be 3-10 characters and contain only a-z and 0-9."
},
"Subnets": {
"Type": "CommaDelimitedList",
"Default": "subnet-8ec5b8e6,subnet-1edcc277",
"Description": "The list of SubnetIds where the stack will be launched"
},
"DBSecurityGroupName": {
"Type": "String",
"Description": "Security Group id"
}
},
"Resources": {
"DBSubnetGroup": {
"Type": "AWS::RDS::DBSubnetGroup",
"Properties": {
"DBSubnetGroupDescription": "Dev DB subent groups",
"SubnetIds":
{
"Ref": "Subnets"
},

"Tags": [
{
"Key": "Name",
"Value": {
"Fn::Join": [
"",
[
"PROJECT_NAME-",
{
"Ref": "EnvironmentName"
},
"-db"
]
]
}
}
]
}
},
"DBCluster": {
"Type": "AWS::RDS::DBCluster",
"Properties": {
"Engine": "aurora",
"MasterUsername": {
"Ref": "DbUsername"
},
"MasterUserPassword": {
"Ref": "DbPassword"
},
"DBSubnetGroupName": {
"Ref": "DBSubnetGroup"
},
"VpcSecurityGroupIds": [
{
"Ref": "DBSecurityGroupName"
}
]
}
},
"RDSinstance": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"DBClusterIdentifier": {
"Ref": "DBCluster"
},
"DBInstanceIdentifier": {
"Ref": "DBIdentifierNameMaster"
},
"DBInstanceClass": {
"Ref": "DbType"
},
"Engine": "aurora",
"DBParameterGroupName": {
"Ref": "DbParameterGroup"
},
"DBSubnetGroupName": {
"Ref": "DBSubnetGroup"
},
"PubliclyAccessible": "true",
"Tags": [
{
"Key": "Name",
"Value": {
"Fn::Join": [
"",
[
"Master Database-",
{
"Ref": "EnvironmentName"
},
"-app-db"
]
]
}
}
]
}
},
"RDSinstance2": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"DBClusterIdentifier": {
"Ref": "DBCluster"
},
"DBInstanceIdentifier": {
"Ref": "DBIdentifierNameReplica"
},
"DBInstanceClass": {
"Ref": "DbType"
},
"Engine": "aurora",
"DBParameterGroupName": {
"Ref": "DbParameterGroup"
},
"DBSubnetGroupName": {
"Ref": "DBSubnetGroup"
},
"PubliclyAccessible": "true",
"Tags": [
{
"Key": "Name",
"Value": {
"Fn::Join": [
"",
[
"Read Replica Database-",
{
"Ref": "EnvironmentName"
},
"-app-db"
]
]
}
}
]
}
},
"DbParameterGroup": {
"Type": "AWS::RDS::DBParameterGroup",
"Properties": {
"Description": "AppDbParameters",
"Family": "aurora5.6",
"Parameters": {
"log_bin_trust_function_creators": "on",
"explicit_defaults_for_timestamp": "0"
}
}
}
}
}

关于amazon-web-services - 如何使用 cloudformation 模板创建 Amazon RDS aurora 主节点和只读副本集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39383724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com