【发布时间】:2021-08-19 02:46:34
【问题描述】:
我在 WAF 后面的 AWS 中的 ECS 实例中有一个微服务,我想创建这些规则:
- 允许特定 IP(完成)
- 允许来自 VPN 内部的所有连接(完成)
- 拒绝所有其他请求。
前两个 IP 集已创建,但我无法使最后一个工作。我尝试使用 0.0.0.0/0 和其他组合创建 IP 集,但没有成功。
这是我的代码,我删除了 ipset 1 和 2(正在工作),这是 ipset 3:
resource "aws_wafv2_ip_set" "ipset" {
name = "${var.app_name}-${var.environment_name}-whitelist-ips"
scope = "REGIONAL"
ip_address_version = "IPV4"
addresses = ["0.0.0.0/0"]
}
module "alb_wafv2" {
source = "trussworks/wafv2/aws"
version = "~> 2.0"
name = "${var.app_name}-${var.environment_name}"
scope = "REGIONAL"
alb_arn = aws_lb.app_lb.arn
associate_alb = true
ip_sets_rule = [
{
name = "${var.app_name}-${var.environment_name}-ip-blacklist"
action = "deny"
priority = 1
ip_set_arn = aws_wafv2_ip_set.ipset.arn
}
]
}
{
RespMetadata: {
StatusCode: 400,
RequestID: "c98b2d3a-ebd0-44e0-a80a-702bc698598b"
},
Field: "IP_ADDRESS",
Message_: "Error reason: The parameter contains formatting that is not valid., field: IP_ADDRESS, parameter: 0.0.0.0/0",
Parameter: "0.0.0.0/0",
Reason: "The parameter contains formatting that is not valid."
}
所以我有两个问题,首先,我该怎么做?第二个,这是最好的方法吗?
提前致谢
【问题讨论】:
-
“我尝试创建” - 你能显示你尝试的带有错误消息的实际代码吗?
-
我的错,我添加了实际代码和输出@Marcin
标签: amazon-web-services terraform terraform-provider-aws web-application-firewall