-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First implementation of terraform event hub for cling * remove sub and tenant from tf * add some variables and org case first draft * Introduce var for message retention days * Introduce var for location * Refactor * Refactor names * Add subscription_id variable and use it in the module * Revamp vars * Update versions.tf * Refactor main.tf * Add module README.md (WIP) * Update README.md * General cleanup * Fix bad subscription reference * WIP * add organizational file * Use list of mgmt groups * remove logs not needed for secure * use same variables as sp module * get tenant if from azurerm config * add service principal outputs * remove outputs * Use variable for orf diagnostics settings name --------- Co-authored-by: Giovanni Recupero <[email protected]>
- Loading branch information
1 parent
e3dc4d4
commit 1d03d95
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
data "azurerm_client_config" "current" {} | ||
|
||
data "azurerm_management_group" "onboarded_management_group" { | ||
for_each = length(var.management_group_ids) > 0 ? toset(var.management_group_ids) : toset([data.azurerm_client_config.current.tenant_id]) | ||
name = each.value | ||
} | ||
|
||
locals { | ||
all_mg_subscription_ids = flatten([ | ||
for mg in data.azurerm_management_group.onboarded_management_group : mg.all_subscription_ids | ||
]) | ||
} | ||
|
||
data "azurerm_subscription" "onboarded_subscriptions" { | ||
for_each = toset(local.all_mg_subscription_ids) | ||
subscription_id = each.value | ||
} | ||
|
||
locals { | ||
enabled_subscriptions = var.is_organizational ? [for s in data.azurerm_subscription.onboarded_subscriptions : s if s.state == "Enabled"] : [] | ||
} | ||
|
||
#--------------------------------------------------------------------------------------------- | ||
# Create diagnostic settings for the tenant | ||
#--------------------------------------------------------------------------------------------- | ||
resource "azurerm_monitor_diagnostic_setting" "sysdig_org_diagnostic_setting" { | ||
count = var.is_organizational ? length(local.enabled_subscriptions) : 0 | ||
|
||
name = var.diagnostic_settings_name | ||
target_resource_id = local.enabled_subscriptions[count.index].id | ||
eventhub_authorization_rule_id = azurerm_eventhub_namespace_authorization_rule.sysdig_rule.id | ||
eventhub_name = azurerm_eventhub.sysdig_event_hub.name | ||
|
||
enabled_log { | ||
category = "Administrative" | ||
} | ||
|
||
enabled_log { | ||
category = "Security" | ||
} | ||
|
||
enabled_log { | ||
category = "Policy" | ||
} | ||
} |
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
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