You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.7KB

  1. ###
  2. # Storage account
  3. ###
  4. module "storage_account" {
  5. source = "git::https://scm.dazzlingwrench.fxinnovation.com/fxinnovation-public/terraform-module-azurerm-storage-account.git?ref=1.0.0"
  6. enabled = var.enabled && var.storage_account_exist == false
  7. storage_account_name = var.storage_account_name
  8. resource_group_name = var.resource_group_name
  9. location = var.resource_group_location
  10. account_tier = var.account_tier
  11. account_replication_type = var.account_replication_type
  12. enable_https_traffic_only = var.enable_https_traffic_only
  13. storage_containers = var.storage_containers
  14. storage_shares = var.storage_shares
  15. tags = merge(
  16. var.tags,
  17. var.storage_account_tags
  18. )
  19. }
  20. ###
  21. # Log analytics workspace
  22. ###
  23. module "log_analytics_workspace" {
  24. source = "git::https://scm.dazzlingwrench.fxinnovation.com/fxinnovation-public/terraform-module-azurerm-log-analytics-workspace.git?ref=1.0.0"
  25. enabled = var.enabled && var.workspace_exist == false
  26. name = var.log_analytics_workspace_name
  27. location = var.resource_group_location
  28. resource_group_name = var.resource_group_name
  29. sku = var.workspace_sku
  30. retention_in_days = var.retention_in_days
  31. tags = merge(
  32. var.tags,
  33. var.log_analytics_workspace_tags
  34. )
  35. }
  36. ###
  37. # Diagnostics settings
  38. ###
  39. resource "azurerm_monitor_diagnostic_setting" "this" {
  40. count = var.enabled ? var.diagnostics_count : 0
  41. name = element(var.names, count.index)
  42. target_resource_id = element(var.target_resource_ids, count.index)
  43. log_analytics_workspace_id = var.workspace_exist != false ? data.azurerm_log_analytics_workspace.this[0].id : module.log_analytics_workspace.id
  44. storage_account_id = var.storage_account_exist != false ? data.azurerm_storage_account.this[0].id : module.storage_account.id
  45. dynamic "log" {
  46. for_each = var.logs[count.index]
  47. content {
  48. category = lookup(log.value, "category", null)
  49. enabled = lookup(log.value, "enabled", true)
  50. dynamic "retention_policy" {
  51. for_each = log.value.retention_policy
  52. content {
  53. enabled = retention_policy.value.enabled
  54. days = retention_policy.value.days
  55. }
  56. }
  57. }
  58. }
  59. dynamic "metric" {
  60. for_each = var.metrics[count.index]
  61. content {
  62. category = lookup(metric.value, "category", null)
  63. enabled = lookup(metric.value, "enabled", true)
  64. dynamic "retention_policy" {
  65. for_each = metric.value.retention_policy
  66. content {
  67. enabled = retention_policy.value.enabled
  68. days = retention_policy.value.days
  69. }
  70. }
  71. }
  72. }
  73. }