1

나는이 AWS :: EC2 ::에는 SecurityGroup 있습니다VPC 컨텍스트에서 AWS :: ECS :: DBSecurityGroup을 AWS :: RDS :: DBSecurityGroup에 어떻게 연결합니까?

"InstanceSecurityGroup" : { 
     "Type" : "AWS::EC2::SecurityGroup", 
     "Properties" : { 
      "GroupDescription" : "Enable HTTP access on the configured port", 
      "VpcId" : { "Ref" : "VpcId" }, 
      "SecurityGroupIngress" : [ { 
       "IpProtocol" : "tcp", 
       "FromPort" : { "Ref" : "WebServerPort" }, 
       "ToPort" : { "Ref" : "WebServerPort" }, 
       "SourceSecurityGroupId" : { "Ref" : "LoadBalancerSecurityGroup" } 
      } ] 
     } 
    } 

을하고 나는이 AWS는 :: RDS :: DBSecurityGroup

"DBSecurityGroup": { 
     "Type": "AWS::RDS::DBSecurityGroup", 
     "Properties": { 
      "DBSecurityGroupIngress": { "EC2SecurityGroupName": { "Ref": "InstanceSecurityGroup"} }, 
      "GroupDescription"  : "Frontend Access" 
     } 
    } 

나는이 스택을 불러올 때, 내가 얻을 수있다 :

Invalid security group , groupId=, groupName= sg-a381fdc6. 

편집 1 : 더 비트를 읽는 것은 내가 AWS : RDS :: DBSecurityGroup 필요 내 VPC과 관련이 제안, 그래서 티로 변경 S :

"DBSecurityGroup": { 
     "Type": "AWS::RDS::DBSecurityGroup", 
     "Properties": { 
      "EC2VpcId" : { "Ref" : "VpcId" }, 
      "DBSecurityGroupIngress": { "EC2SecurityGroupName": { "Ref": "InstanceSecurityGroup"} }, 
      "GroupDescription"  : "Frontend Access" 
     } 
    } 

내가 스택을 가져올 때이

이 DBSecurityGroup의 진입을 허가 설명서를 참조하십시오 얻을. VPC의 경우 EC2SecurityGroupId가 필요합니다. 이 요청의 원본 주소 (및 다른 주소 없음) 만 권한을 부여하려면 205.251.233.35/32를 CIDRIP 매개 변수로 전달하십시오.

EC2SecurityGroupId는 이름이 아닌 보안 그룹의 ID이며 해당 ID는 내 컨트롤 외부에 할당되므로 여기에 입력 할 값을 알지 못합니다.

VPC 컨텍스트에서 내 AWS :: ECS :: DBSecurityGroup을 AWS :: RDS :: DBSecurityGroup에 어떻게 연결합니까?

답변

5

문제는 당신 { "Ref": "InstanceSecurityGroup"} 그 이드는 이드 만이 지니고 있지 않습니다. EC2SecurityGroupId을 보류하려면 Fn::GetAtt을 사용하십시오.

이 같은 (참고는 FN에 의해 ​​대체되었습니다 어떻게 알을 보여야 DBSecurityGroup에 대한 귀하의 템플릿 :: GetAtt :

"DBSecurityGroup": { 
"Type": "AWS::RDS::DBSecurityGroup", 
"Properties": { 
    "EC2VpcId"    : { "Ref" : "VpcId" }, 
    "DBSecurityGroupIngress": { "EC2SecurityGroupId": { "Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ] } }, 
    "GroupDescription"  : "Frontend Access" 
} 
0

RDS 보안 그룹이 VPC 내에 정의되어 있으면 그룹 이름이 아닌 그룹 ID별로 다른 보안 그룹을 참조해야합니다.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-security-group.html http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-security-group-rule.html

페이지의 "VPC DB 보안 그룹에 대한 는, EC2 보안 그룹의 경우 EC2SecurityGroupId.를 사용 EC2SecurityGroupOwnerId 및 중 EC2SecurityGroupName 또는 EC2SecurityGroupId를 사용합니다."

당신은 여기 그래서 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html

을 설명 된대로 "참조"기능을 사용하여 보안 그룹 ID를 얻을 수정 된 보안 그룹이 있어야 할 수 있습니다

"DBSecurityGroup": { "Type": "AWS::RDS::DBSecurityGroup", "Properties": { "EC2VpcId" : { "Ref" : "VpcId" }, "DBSecurityGroupIngress": { "EC2SecurityGroupId": { "Ref": "InstanceSecurityGroup"} }, "GroupDescription" : "Frontend Access" } }