Fn:适用于AWS :: RDS :: DBSubnetGroup对象的GetAtt

时间:2016-01-19 20:34:43

标签: amazon-web-services amazon-cloudformation

我正在尝试创建一个在VPC中包含AWS :: RDS :: DBInstance的堆栈模板。其中一个要求是引用DBSubnetGroupName属性中的子网组。已创建VPC和两个子网(使用可单击的Web界面)。如何在DBSubnetGroupName属性中引用新创建的子网组?

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "THUNDER STACK TEMPLATE - MSSQL RDS",
  "Parameters": {},
  "Mappings" : {},
  "Resources": {
    "ThunderSubnetGroup": {
      "Type" : "AWS::RDS::DBSubnetGroup",
      "Properties" : {
        "DBSubnetGroupDescription" : "popissss",
        "SubnetIds" : [ "subnet-ff8450d5", "subnet-3445ff42" ]
      }
    },
    "ThunderSG": {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupDescription" : "opisss",
        "SecurityGroupIngress" : {
        "CidrIp" : "0.0.0.0/0",
          "FromPort" : "1433",
          "IpProtocol" : "tcp",
          "ToPort" : "1433"
        },
        "VpcId" : "vpc-8eaaaab"
      }
    },
    "ThunderRDS": {
      "Type": "AWS::RDS::DBInstance",
      "Properties": {
        "AvailabilityZone": "us-east-1b",
        "Engine": "sqlserver-ex",
        "EngineVersion": "12.00.4422.0.v1",
        "MasterUsername": "username",
        "DBInstanceClass": "db.t2.micro",
        "DBInstanceIdentifier" : "thunder-rds",
        "DBSubnetGroupName" : "ThunderSubnetGroup",
        "AllocatedStorage": "5",
        "MasterUserPassword": "password",
        "VPCSecurityGroups": [{ "Fn::GetAtt": [ "ThunderSG", "GroupId" ] }]
      }
    }
  },
  "Outputs": {}
}

尝试上面的代码时,我收到错误:

DBSubnetGroup 'thundersubnetgroup' not found.

我也尝试使用Fn:GetAtt函数但在设计器中验证模板时出错:

Template contains errors.: Template error: resource ThunderSubnetGroup does not support attribute type DBSubnetGroupName in Fn::GetAtt

1 个答案:

答案 0 :(得分:1)

使用:

"DBSubnetGroupName" : {"Ref": "ThunderSubnetGroup"},

另见:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html