如何通过 AWS 中的 Cloudformation 设置入站规则名称

How to set Inbound Rule Name via Cloudformation in AWS

我正在尝试在我的安全组中设置此入口规则的名称:

我尝试了两种方法并查看了文档,但找不到实现的方法。我试过:

      SecurityGroupIngress:
      - IpProtocol: icmp
        FromPort: 0
        ToPort: -1
        Name: Allow ICMP
        Description: Allow ICMP 
        CidrIp: 0.0.0.0/0

我试过这个:

      SecurityGroupIngress:
      - IpProtocol: icmp
        FromPort: 0
        ToPort: -1
        Description: Allow ICMP 
        CidrIp: 0.0.0.0/0
        Tags:
        - Key: Name
          Value: Allow ICMP

我查找了示例,并查看了文档,但没有看到对此的引用。有什么想法吗?

您在控制台看到的Name就是资源的Name标签。当前在 CloudFormation 中,AWS::EC2::SecurityGroup 中的 AWS::EC2::SecurityGroupIngressIngress 对象都不支持标签(单个规则的标签是最近的一项功能,在 July 2021. CloudFormation doesn't support all new features on release). If this is a crucial requirement you can use Lambda backed custom CloudFormation resources 中添加以创建 AWS Lambda 函数它将为您标记资源。