【问题标题】:self-reference not allowed in Security Group definition安全组定义中不允许自引用
【发布时间】:2018-10-04 08:17:15
【问题描述】:

我正在尝试使用 Terraform 创建一个 sg。

我希望特定 SG 的所有实例都允许它们之间的所有通信,因此我将 SG 本身添加到入口规则中,如下所示:

resource "aws_security_group" "rancher-server-sg" {
  vpc_id = "${aws_vpc.rancher-vpc.id}"
  name = "rancher-server-sg"
  description = "security group for rancher server"

  ingress {
      from_port = 0
      to_port = 0
      protocol = -1
      security_groups = ["${aws_security_group.rancher-server-sg.id}"]              
  }

但是在运行terraform plan 时,我得到:


但是,在 AWS 控制台中,我可以在入站规则中添加 SG 名称,并且我看到我可以添加组本身(即自引用)。

为什么会这样?

我也试过这个没有成功:

security_groups = ["${self.id}"]

【问题讨论】:

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


    【解决方案1】:

    引用the manual

    self - (可选)如果为真,安全组本身将被添加为 此入口规则的来源。

      ingress {
          from_port = 0
          to_port = 0
          protocol = -1
          self = true
      }
    

    【讨论】:

      猜你喜欢
      • 2016-12-23
      • 2016-11-21
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 2014-09-24
      • 2019-05-01
      • 2012-10-24
      • 2018-04-19
      相关资源
      最近更新 更多