3

인스턴스와 db를 동시에 vpc로 시작하는 CLoudFormation 스크립트를 작성하려고합니다. 문제는 db가 두 개의 AZ를 필요로하므로 두 번째 서브넷을 만들고 지금은 'MyDBSubnetGroup'var에 두 개의 서브넷 물리적 ID를 참조해야합니다. 내가 만든 서브넷에 대한 논리적 ID를 얻을 수 있지만 그 물리적 ID를 참조하는 방법을 모릅니다. 아무도 몰라? 감사!!가상 서브넷 그룹의 문자열을 생성하여 클라우드 정보 스크립트에서 즉석에서 db 서브넷 그룹을 생성하는 방법은 무엇입니까?

Heres는 내 코드 : 저도 같은 문제로 실행

"MyDBSubnetGroup" : { 
     "Type" : "AWS::RDS::DBSubnetGroup", 
     "Properties" : { 
     "DBSubnetGroupDescription" : "Subnets available for the RDS DB Instance", 
     "SubnetIds" : { "Fn::Join" : [ " ", [{"Ref" : "PublicSubnetAZ1"}, ", ", {"Ref" : "PublicSubnetAZ2"}, " " ]]} 
     } 
    }, 

답변

4

, AWS 지원 작업을 한 후 나는 우리가 처음에 생각했던 것은 아니다 문자열의 목록을 이해했다. 또한 DB를 VPC에 넣으려면 AWS::RDS::DBSecurityGroup 개체를 사용하지 않아야합니다.

여기 전체 샘플입니다, 그것은 작업을 진행 걸 렸어요 :

"dbSubnetGroup" : { 
     "Type" : "AWS::RDS::DBSubnetGroup", 
     "Properties" : { 
      "DBSubnetGroupDescription" : "Availability Zones for RDS DB", 
      "SubnetIds" : [ { "Ref" : "subnetPrivate1" }, 
          { "Ref" : "subnetPrivate2" } ] 
     } 
}, 
"dbInstance" : { 
     "Type" : "AWS::RDS::DBInstance", 
     "Properties" : { 
      "DBInstanceIdentifier" : { "Fn::Join" : [ "", 
                [ { "Ref" : "AWS::StackName" }, 
                 "DB" ] ] }, 
      "DBName" : "dbname", 
      "DBSubnetGroupName" : { "Ref" : "dbSubnetGroup" }, 
      "MultiAZ" : "true", 
      "AllocatedStorage" : "8", 
      "BackupRetentionPeriod" : "0", 
      "DBInstanceClass" : "db.m1.medium", 
      "Engine" : "postgres", 
      "MasterUserPassword" : "masteruserpassword", 
      "MasterUsername" : "masterusername", 
      "VPCSecurityGroups" : [ { "Ref" : "sgVpc" }, { "Ref" : "sgDB" } ] 
    } 
}, 
2

당신이 이런 일에 액세스 할 수 있습니다 서브넷 ID를 매핑합니다.

 "AWSRegionSubnet":{ 
     "us-east-1":{ 
      "RDSSubnets":[ 
       "subnet-aaaaaaaa", 
       "subnet-bbbbbbbb" 
      ] 

     }, 
     "us-west-2":{ 
      "RDSSubnets":[ 
       "subnet-cccccccc", 
       "subnet-dddddddd" 
      ] 
     } 
    } 

     "RDSSubnet":{ 
     "Type":"AWS::RDS::DBSubnetGroup", 
     "Properties":{ 
      "DBSubnetGroupDescription":"Some cool notes here", 
      "SubnetIds":{ 
       "Fn::FindInMap":[ 
        "AWSRegionSubnet", 
        { 
         "Ref":"AWS::Region" 
        }, 
        "RDSSubnets" 
       ] 
      } 
     } 
    }