Skip to content

Commit 60c078b

Browse files
committed
terraform stuff
1 parent f4afa3e commit 60c078b

4 files changed

Lines changed: 70 additions & 1 deletion

File tree

infrastructure/environments/nonlive-hub/variables.tfvars

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ avd_source_image_from_gallery = {
3434
gallery_rg_name = "rg-hub-dev-uks-hub-virtual-desktop"
3535
}
3636

37+
law = {
38+
export_enabled = false
39+
law_sku = "PerGB2018"
40+
retention_days = 30
41+
}
42+
3743
regions = {
3844
uksouth = {
3945
address_space = "10.65.0.0/16"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module "log_analytics_workspace_hub" {
2+
for_each = var.regions
3+
4+
source = "../../../../dtos-devops-templates/infrastructure/modules/log-analytics-workspace"
5+
6+
name = module.config[each.key].names.log-analytics-workspace
7+
resource_group_name = azurerm_resource_group.rg_base[each.key].name
8+
location = each.key
9+
10+
law_sku = var.law.law_sku
11+
retention_days = var.law.retention_days
12+
13+
monitor_diagnostic_setting_log_analytics_workspace_enabled_logs = local.monitor_diagnostic_setting_log_analytics_workspace_enabled_logs
14+
monitor_diagnostic_setting_log_analytics_workspace_metrics = local.monitor_diagnostic_setting_log_analytics_workspace_metrics
15+
16+
tags = var.tags
17+
}
18+
19+
# Add a data export rule to forward logs to the Event Hub in the Hub subscription
20+
module "log_analytics_data_export_rule" {
21+
for_each = var.features.log_analytics_data_export_rule_enabled ? var.regions : {}
22+
23+
source = "../../../../dtos-devops-templates/infrastructure/modules/log-analytics-data-export-rule"
24+
25+
name = "${module.config[each.key].names.log-analytics-workspace}-export-rule"
26+
resource_group_name = azurerm_resource_group.rg_base[each.key].name
27+
workspace_resource_id = module.log_analytics_workspace_hub[each.key].id
28+
destination_resource_id = module.eventhub_law_export["dtos-hub-${each.key}"].event_hubs["dtos-hub"].id
29+
table_names = var.law.export_table_names
30+
enabled = var.law.export_enabled
31+
}
32+
33+
/*--------------------------------------------------------------------------------------------------
34+
RBAC Assignments
35+
--------------------------------------------------------------------------------------------------*/
36+
/*
37+
For sending events to the Event Hub:
38+
* Azure Event Hubs Data Sender: Grants permissions to send events to the Event Hub.
39+
* For receiving events from the Event Hub:
40+
41+
For receiving events from the Event Hub (i.e. remote resource):
42+
* Azure Event Hubs Data Receiver: Grants permissions to receive events from the Event Hub.
43+
*/
44+
# module "rbac_assignments" {
45+
# for_each = var.regions
46+
47+
# source = "../../../dtos-devops-templates/infrastructure/modules/rbac-assignment"
48+
49+
# principal_id = module.log_analytics_workspace_audit[each.key].0.principal_id
50+
# role_definition_name = "Azure Event Hubs Data Sender"
51+
# scope = data.terraform_remote_state.hub.outputs.eventhub_law_export_id["dtos-hub-${each.key}"]
52+
# }

infrastructure/terraform/hub/networking_hub.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module "subnets_hub" {
3838

3939
source = "../../../../dtos-devops-templates/infrastructure/modules/subnet"
4040

41-
# log_analytics_workspace_id = module.log_analytics_workspace_hub[local.primary_region].id
41+
log_analytics_workspace_id = module.log_analytics_workspace_hub[local.primary_region].id
4242
monitor_diagnostic_setting_network_security_group_enabled_logs = local.monitor_diagnostic_setting_network_security_group_enabled_logs
4343

4444
name = each.value.subnet_name

infrastructure/terraform/hub/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ variable "tags" {
256256
default = {}
257257
}
258258

259+
variable "law" {
260+
description = "Configuration of the Log Analytics Workspace"
261+
type = object({
262+
name = optional(string, "hub")
263+
export_enabled = optional(bool, false)
264+
law_sku = optional(string, "PerGB2018")
265+
retention_days = optional(number, 30)
266+
export_table_names = optional(list(string))
267+
})
268+
}
269+
259270
variable "virtual_desktop_group_active" {
260271
description = <<-EOT
261272
This can either be 'blue', 'green', 'both-with-blue-primary', 'both-with-green-primary', 'both-with-blue-primary-but-equal-vms' or 'both-with-green-primary-but-equal-vms'.

0 commit comments

Comments
 (0)