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

pka*_*mol 10 amazon-web-services terraform aws-security-group terraform-provider-aws

我正在尝试创建一个sg terraform plan.

我希望特定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}"]              
  }
Run Code Online (Sandbox Code Playgroud)

但是在跑步时terraform plan,我得到:

terraform plan

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

这是为什么?

编辑:也试过这个没有成功:


Run Code Online (Sandbox Code Playgroud)

Jak*_*nia 26

引用手册:

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

  ingress {
      from_port = 0
      to_port = 0
      protocol = -1
      self = true
  }
Run Code Online (Sandbox Code Playgroud)