Skip to content

Instantly share code, notes, and snippets.

@reespozzi
Created February 3, 2023 15:42
Show Gist options
  • Save reespozzi/b8fbce5d5b0953aa6a761b4c1890c96e to your computer and use it in GitHub Desktop.
Save reespozzi/b8fbce5d5b0953aa6a761b4c1890c96e to your computer and use it in GitHub Desktop.
Terraform Conditional Dynamic Block example
resource "azurerm_monitor_diagnostic_setting" "my_mds" {
name = "my-mds"
target_resource_id = azurerm_virtual_network.my_vnet.id
log_analytics_workspace_id = azurerm_log_analytics_workspace.my_ws.id
dynamic "enabled_log" {
for_each = var.my_condition ? [1] : []
content {
category = "AuditEvent"
retention_policy {
enabled = true
days = 90
}
}
}
metric {
category = "AllMetrics"
retention_policy {
enabled = true
days = 90
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment