通过Terraform添加AWS安全组时出现问题



我正在通过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 "
}

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

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

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

最新更新