是否可以使用 Cloudformation 删除 aws 安全组默认出口允许所有规则?

sou*_*a49 6 amazon-web-services aws-cloudformation

我知道 terraform 确实删除了 AWS 的默认行为。但是可以使用 cloudformation 做到这一点吗?

Mar*_*cin 8

CloudFormation 文档有专门的部分:

当您指定 VPC 安全组时,Amazon EC2 会创建一条默认出口规则,允许所有端口和 IP 协议上的出口流量到达任何位置。仅当您指定一项或多项出口规则时,才会删除默认规则。如果要删除默认规则并将出口流量限制为仅 localhost (127.0.0.1/32),请使用以下示例。

sgwithoutegress:
  Type: AWS::EC2::SecurityGroup
  Properties:
    GroupDescription: Limits security group egress traffic
    SecurityGroupEgress:
    - CidrIp: 127.0.0.1/32
      IpProtocol: "-1"
    VpcId:
      Ref: myVPC
Run Code Online (Sandbox Code Playgroud)

这并不是说这不会从安全组中物理删除出口规则。这将导致创建以下出口规则:

在此输入图像描述

而不是默认的:

在此输入图像描述

  • 是的..它允许通过规则...但我根本不想在出站中有任何规则... Cloudformation 是否可以? (3认同)