安全组定义中不允许自引用。

22

我正在尝试使用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}"]
1个回答

58

引用手册:

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

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

这是否意味着您不为出站属性提供 cidr_blocks 值? - user1091968
更新了手册的链接。 - LisaF

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接