Cloudformation AWS:将RDS连接到子网

时间:2018-10-16 08:46:38

标签: oracle amazon-web-services amazon-cloudformation

我正在尝试构建cloudformation模板,但是在如何将Oracle RDS实例与两个子网连接时遇到了一些麻烦。
我的参数是:

"3DCFDB": {
        "Type": "AWS::RDS::DBInstance",
        "Properties": {
            "DBInstanceClass": "db.t2.micro",
            "AllocatedStorage": "20",
            "Engine": "oracle-se2",
            "EngineVersion": "12.1.0.2.v13",
            "MasterUsername": {
                "Ref": "user"
            },
            "MasterUserPassword": {
                "Ref": "password"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "*"
            }
        },
        "DependsOn": [
            "3DEXPSUBPU",
            "3DSUBPRI"
        ]
    }

我应该添加什么参数以将RDS连接到2个子网?

1 个答案:

答案 0 :(得分:3)

如果我理解正确,则需要创建一个类型为"Type": AWS::RDS::DBSubnetGroup的资源,然后在"Type": "AWS::RDS::DBInstance"内可以引用与此类似的子网组

"3DCFDB": {
    "Type": "AWS::RDS::DBInstance",
    "Properties": {
        "DBInstanceClass": "db.t2.micro",
        "AllocatedStorage": "20",
        "Engine": "oracle-se2",
        "EngineVersion": "12.1.0.2.v13",
        "DBSubnetGroupName": {
           "Ref": "DBsubnetGroup"
        }
        "MasterUsername": {
            "Ref": "user"
        },
        "MasterUserPassword": {
            "Ref": "password"
        }
    },
    "Metadata": {
        "AWS::CloudFormation::Designer": {
            "id": "*"
        }
    },
    "DependsOn": [
        "3DEXPSUBPU",
        "3DSUBPRI"
    ]
},
"DBsubnetGroup": {
 "Type" : "AWS::RDS::DBSubnetGroup",
 ...
 ...
 }

更多信息可以在这里找到

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbsubnet-group.html