[英]How to append or delete the ingress/egress rule for a security group using Terraform?
[英]How should I define ranges in ingress security group using terraform?
我找不到如何在入口安全组中使用 terraform 定义范围。 检查文档字段to_port
和from_port
范围端口。 但是,我找不到如何配置它。
使用 aws CLI 的工作示例:
aws ec2 authorize-security-group-ingress \
--region $REGION \
--group-name test \
--protocol tcp \
--port 50000-50001 \
--cidr 0.0.0.0/0
但我无法使用 terraform 做同样的事情。 我尝试在安全组资源中配置相同的内容:
resource "aws_security_group" "allow_tls" {
name = "allow_tls"
description = "Allow TLS inbound traffic"
vpc_id = aws_vpc.main.id
ingress {
description = "allow_tls"
from_port = 50000-50001
to_port = 50000-50001
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "allow_tls"
}
}
我遇到的问题是它会自动将to_port
和from_port
设置为-1
值。
# from terraform plan output
+ cidr_blocks = [
+ "0.0.0.0/0",
]
+ description = "allow_tls"
+ from_port = -1
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = false
+ to_port = -1
}
也尝试使用aws_security_group_rule
并且它具有相同的行为。 知道如何解决吗?
它应该是:
from_port = 50000
to_port = 50001
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.