【问题标题】:Issue while adding AWS Security Group via Terraform通过 Terraform 添加 AWS 安全组时出现问题
【发布时间】:2021-05-08 12:53:44
【问题描述】:

我正在通过 terraform 添加安全组,并且在 terraform 应用后成功创建了 SG,但是当我去查看 AWS 门户时,只有入口规则被更新,而不是出口规则。

  vpc_id      = var.vpc_id
  name        = "${var.env_code}-testsg"
  description = "Test SG"

  ingress {
    from_port       = 8080
    to_port         = 8080
    protocol        = "tcp"
    cidr_blocks = ["10.0.0.0/8"]
    description = "Incoming traffic "
  }

  egress {
    from_port   = 8000
    to_port     = 8000
    protocol    = "tcp"
    description = "Outbound traffic "
  }

有什么建议可以解决这个问题吗?

【问题讨论】:

    标签: amazon-web-services terraform terraform-provider-aws aws-security-group


    【解决方案1】:

    您的egress缺少目的地,例如cidr_blockssecurity_groups,因此无效。要解决这个问题,您需要一些目的地来应用规则,例如:

      egress {
        from_port   = 8000
        to_port     = 8000
        protocol    = "tcp"
        cidr_blocks = ["0.0.0.0/0"]
        description = "Outbound traffic "
      }
    

    【讨论】:

    • 哦,是的,缺少 cidr 块。非常感谢:)
    • @Legitimate_Figure_4430 没问题。很高兴它起作用了:-)
    猜你喜欢
    • 2019-08-20
    • 2021-08-08
    • 2021-07-13
    • 2021-04-06
    • 1970-01-01
    • 2020-05-30
    • 2021-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多