Created
February 3, 2023 15:42
-
-
Save reespozzi/b8fbce5d5b0953aa6a761b4c1890c96e to your computer and use it in GitHub Desktop.
Terraform Conditional Dynamic Block example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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