感谢您提前提供的帮助和时间。
我正在尝试为 AWS 网络防火墙配置创建 terraform 模块。
下面是我的代码:
firewall_arn = var.firewall_arn
logging_configuration {
dynamic "config" {
for_each = var.log_destination_configs
content {
log_destination {
bucketName = lookup(config.value, "bucketName", null)
prefix = lookup(config.value, "prefix", null)
logGroup = lookup(config.value, "logGroup", null)
deliveryStream = lookup(config.value, "deliveryStream", null)
}
log_destination_type = lookup(config.value, "log_destination_type", null)
log_type = lookup(config.value, "log_type", null)
}
}
}
}
但是,当我尝试编译时,出现以下错误:
Error: Unsupported block type
on ../../main.tf line 4, in resource "aws_networkfirewall_logging_configuration" "default":
4: dynamic "config" {
Blocks of type "config" are not expected here.
}
是不是因为我在 logging_configuration 中声明了块而这是不允许的?
再次感谢。
答案 0 :(得分:0)
根据 logging_configuration argument documentation,嵌套块被命名为 log_destination_config
而不是 config
。这就是为什么错误消息指出该块中不存在块 config
。如果您相应地更新块名称和 lambda 范围变量:
logging_configuration {
dynamic "log_destination_config" {
for_each = var.log_destination_configs
content {
log_destination {
bucketName = lookup(log_destination_config.value, "bucketName", null)
prefix = lookup(log_destination_config.value, "prefix", null)
logGroup = lookup(log_destination_config.value, "logGroup", null)
deliveryStream = lookup(log_destination_config.value, "deliveryStream", null)
}
log_destination_type = lookup(log_destination_config.value, "log_destination_type", null)
log_type = lookup(log_destination_config.value, "log_type", null)
}
}
}
那么这应该可以解决围绕您的错误消息的问题。