terraform - Terraform - 除非启用,否则不要在防火墙规则上创建 log_config
问题描述
我正在尝试在 GCP 中创建一些防火墙规则,这些规则可以选择打开或关闭日志记录。
resource "google_compute_firewall" "this" {
name = var.name
project = var.project
network = var.network
source_ranges = var.source_ranges
source_tags = var.source_tags
target_tags = var.target_tags
priority = var.priority
direction = var.direction
allow {
protocol = lower(var.protocol)
ports = var.ports
}
## If log_config is defined, this enables logging. By not defining it, we are disabling logging.
log_config {
metadata = var.log_metadata
}
}
我需要实现并且无法弄清楚的是,当我将 var.firewall_logging 设置为 true (或其他字符串,如果我们不能使用布尔值)并且没有 log_config 块时,如何定义 log_config 块当它设置为假时。我尝试使用动态,就像我的其他问题Optional fields in resource然而,即使设置为 false,它仍在创建 log_config 块。
解决方案
推荐阅读
- javascript - 事件列表中没有链接
- php - (laravel)如何在更新时使用唯一的验证请求
- node.js - Firebase Cloud Functions 提高时间限制
- r - 在表 r 中找到最右边的值
- react-native - 如何使用 expo-sqlite 执行带有 typescript 的 sql?
- c - FLT_HAS_SUBNORM 为 0:什么 fpclassify(
) 应返回:FP_SUBNORMAL 或 FP_ZERO,还是导致 UB? - python - Openpyxl:从使用 wb.remove_sheet(ws) 的工作簿创建的 .xlsx 打开时出现错误消息
- python - 阻止 ytdl 向控制台发送消息
- flutter - 如何在颤振应用程序中导航修复屏幕的一部分?
- javascript - 分页 PHP + 图库 HTML / 脚本