向AWS Cloudformation中的安全组Ingress数组元素添加描述

时间:2019-01-09 10:06:42

标签: amazon-web-services amazon-cloudformation

在Cloudformation中,是否可以像下面的示例一样添加安全组描述?

我在文档(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-rule.html)中看到过,但我从未见过1个官方示例,其中仅对GroupDescription进行了IP规则的描述。我发现这非常有帮助,因为它有助于识别IP所指的内容。 那么,例如,这些示例片段是否有效?

"InstanceSecurityGroup" : {
   "Type" : "AWS::EC2::SecurityGroup",
   "Properties" : {
      "GroupDescription" : "Enable SSH access via port 22",
      "SecurityGroupIngress" : [ {
         "IpProtocol" : "tcp",
         "FromPort" : 22,
         "ToPort" : 22,
         "CidrIp" : "0.0.0.0/0",
         "Description" : "some description" <<<<<<<<<here
      } ]
   }
}

其他示例

 LoadBalancerSG:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupName: !Join ['-', [!Ref 'StackName', 'LoadBalancerSG']]
      GroupDescription: Access to the load balancer
      VpcId:
        Fn::ImportValue: 'VpcID'
      SecurityGroupIngress:
      - IpProtocol: tcp
        Description: 'this IP is ...' <<<<< here
        CidrIp: 10.5.0.0/14
        FromPort: '80'
        ToPort: '80'
      - IpProtocol: tcp
        Description: 'this other IP is ...' <<<<<< here
        CidrIp: 10.5.0.0/14
        FromPort: '8080'
        ToPort: '8080'

1 个答案:

答案 0 :(得分:0)

“ SecurityGroupIngress”:[           {             “ IpProtocol”:“ tcp”,             “ CidrIp”:“ aa.xx.yy.zz / 32”,             “ FromPort”:“ 0000”,             “ ToPort”:“ 0000”           },           {             “ IpProtocol”:“ tcp”,             “ CidrIp”:“ bb.xx.yy.zz / 32”,             “ FromPort”:“ 0000”,             “ ToPort”:“ 0000”           },           {             “ IpProtocol”:“ tcp”,             “描述”:“ ELB-EC2”,             “ SourceSecurityGroupId”:“ sg-nnnnnnnnnnnnn”,             “ FromPort”:“ 000”,             “ ToPort”:“ 000”           }         ]

出于安全目的已更改了实际值,但否则这是一个有效的模板