Azure / Azure/Azure-Landing-Zones

Add data_collection_rule_id field to the landing zone resource

Open
#508 1 comment 1 reaction 0 assignees View on GitHub
Transfer From: caf-enterprise-scale :arrow_right:
Dominant language
PowerShell
Stars
96
Forks
70
Avg merge
3d 1h
Merged PRs (30d)
7

Description

### Community Note

- Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment

### Description
Currently the resource "**azurerm_log_analytics_workspace**" "**management**" resource block does not have the
**data_collection_rule_id** attribute added. It is an optional field in azurerm_log_analytics_workspace.On provisioning the log analytics we have to manually assign the data_collection_rule_id ,but whenever there is a TF run the manual changes gets overridden.

#### Is your feature request related to a problem?
No. It is a new feature attribute that would help in configuring the data collection

resource "azurerm_log_analytics_workspace" "management" {
for_each = local.azurerm_log_analytics_workspace_management

provider = azurerm.management

# Mandatory resource attributes
name = each.value.template.name
location = each.value.template.location
resource_group_name = each.value.template.resource_group_name

# Optional resource attributes
sku = each.value.template.sku
retention_in_days = each.value.template.retention_in_days
daily_quota_gb = each.value.template.daily_quota_gb
cmk_for_query_forced = each.value.template.cmk_for_query_forced
internet_ingestion_enabled = each.value.template.internet_ingestion_enabled
internet_query_enabled = each.value.template.internet_query_enabled
reservation_capacity_in_gb_per_day = each.value.template.reservation_capacity_in_gb_per_day
tags = each.value.template.tags

# allow_resource_only_permissions = each.value.template.allow_resource_only_permissions # Available only in v3.36.0 onwards

# Set explicit dependency on Resource Group deployment
depends_on = [
azurerm_resource_group.management,
]

}

Clearly the block above from the landing zone log analytics source code do not have the optional attribute data_collection_rule_id added under the # Optional resource attributes. After every run the manfully assigned value gets deleted as show below

~ resource "azurerm_log_analytics_workspace" "management" {
- data_collection_rule_id = **"/subscriptions/Masked/resourceGroups/MAsked/providers/Microsoft.Insights/dataCollectionRules/ServiceAccounts_Exclusion" -> null**
id = "/subscriptions/4c526d48-4f3e-462b-b979-61011fcae45e/resourceGroups/jci-mgmt/providers/Microsoft.OperationalInsights/workspaces/jci-la"
name = ""
tags = {
"deployedBy" = "terraform/azure/caf-enterprise-scale"
}

#### Describe the solution you'd like
We could add a variable for data_collection_rule_id under the custom settings and have the same refereed in the azurem resource block of the log_analytics.IF the variable is set it would take the value ,else null

azurerm_log_analytics_workspace = {
name = lookup(local.custom_settings_la_workspace, "name", "${local.resource_prefix}-la${local.resource_suffix}")
resource_group_name = lookup(local.custom_settings_la_workspace, "resource_group_name", local.resource_group_name)
location = lookup(local.custom_settings_la_workspace, "location", local.location)
allow_resource_only_permissions = lookup(local.custom_settings_la_workspace, "allow_resource_only_permissions", true) # Available only in v3.36.0 onwards
sku = lookup(local.custom_settings_la_workspace, "sku", "PerGB2018")
retention_in_days = lookup(local.custom_settings_la_workspace, "retention_in_days", local.settings.log_analytics.config.retention_in_days)
daily_quota_gb = lookup(local.custom_settings_la_workspace, "daily_quota_gb", null)
cmk_for_query_forced = lookup(local.custom_settings_la_workspace, "cmk_for_query_forced", null)
internet_ingestion_enabled = lookup(local.custom_settings_la_workspace, "internet_ingestion_enabled", true)
internet_query_enabled = lookup(local.custom_settings_la_workspace, "internet_query_enabled", true)
reservation_capacity_in_gb_per_day = lookup(local.custom_settings_la_workspace, "reservation_capacity_in_gb_per_day", null)
tags = lookup(local.custom_settings_la_workspace, "tags", local.tags)
}
}

#### Additional context

Contributor guide

Open the contributing guide

Research direction

Locate the landing zone configuration that defines the azurerm_log_analytics_workspace resource and its custom settings object. Add the optional data_collection_rule_id setting and its reference in the resource block, then verify that configured values persist across Terraform runs and that an unset value remains null.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, terraform
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.