通过 Terraform 添加 AWS 安全组时出现问题
Issue while adding AWS Security Group via Terraform
我正在通过 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_blocks
或security_groups
,因此无效。要解决这个问题,您需要一些目的地来应用规则,例如:
egress {
from_port = 8000
to_port = 8000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "Outbound traffic "
}
我正在通过 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_blocks
或security_groups
,因此无效。要解决这个问题,您需要一些目的地来应用规则,例如:
egress {
from_port = 8000
to_port = 8000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "Outbound traffic "
}