0
votes

I am trying to create a stack template that contains an AWS::RDS::DBInstance in a VPC. One of the requirements for that is referencing the subnet group in the DBSubnetGroupName property. The VPC and two subnets are already created (using the clickable web interface). How can I reference the newly created subnet group in the DBSubnetGroupName property?

{
  "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": {}
}

When trying above code I get error:

DBSubnetGroup 'thundersubnetgroup' not found.

I also tried with the Fn:GetAtt function but got error when validated template in the designer:

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

1 Answers

2
votes