### Terraform Configuration for Network Isolation Source: https://github.com/azure/terraform-azurerm-avm-res-operationalinsights-workspace/blob/main/examples/deploy_network_isolation/README.md This configuration sets up the necessary Terraform providers, modules, and resources for deploying a network-isolated Log Analytics Workspace. It includes configurations for naming, random region selection, resource group, virtual network, subnet, private DNS zone, and the Log Analytics Workspace module itself. ```hcl terraform { required_version = "~> 1.5" required_providers { azapi = { source = "Azure/azapi" version = "~> 2.0" } azurerm = { source = "hashicorp/azurerm" version = ">= 4.36.0, < 5.0.0" } random = { source = "hashicorp/random" version = "~> 3.5" } } } provider "azurerm" { #subscription_id = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" features { resource_group { prevent_deletion_if_contains_resources = true } } } provider "azapi" { use_cli = true use_msi = false } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.1" } # This picks a random region from the list of regions. resource "random_integer" "region_index" { max = length(local.azure_regions) - 1 min = 0 } # This is required for resource modules resource "azurerm_resource_group" "this" { location = local.azure_regions[random_integer.region_index.result] name = module.naming.resource_group.name_unique } resource "azurerm_virtual_network" "this" { location = azurerm_resource_group.this.location name = module.naming.virtual_network.name_unique resource_group_name = azurerm_resource_group.this.name address_space = ["192.168.0.0/24"] } resource "azurerm_subnet" "this" { address_prefixes = ["192.168.0.0/24"] name = module.naming.subnet.name_unique resource_group_name = azurerm_resource_group.this.name virtual_network_name = azurerm_virtual_network.this.name } module "privatednszone" { source = "Azure/avm-res-network-privatednszone/azurerm" version = "0.3.2" domain_name = "privatelink.monitor.azure.com" resource_group_name = azurerm_resource_group.this.name virtual_network_links = { vnetlink0 = { vnetlinkname = "dnslinktovnet" vnetid = azurerm_virtual_network.this.id } } } # This is the module call module "law" { source = "../../" location = azurerm_resource_group.this.location name = "thislaworkspace" resource_group_name = azurerm_resource_group.this.name # source = "Azure/avm-res-operationalinsights-workspace/azurerm" enable_telemetry = var.enable_telemetry log_analytics_workspace_identity = { type = "SystemAssigned" } log_analytics_workspace_retention_in_days = 30 log_analytics_workspace_sku = "PerGB2018" monitor_private_link_scope = { pe1 = { name = "law_pl_scope" resource_id = azurerm_resource_group.this.id } } monitor_private_link_scoped_service_name = "law_pl_service" private_endpoints = { pe1 = { subnet_resource_id = azurerm_subnet.this.id network_interface_name = "nic1" private_dns_zone_group_name = "dnslinktovnet" } } } ``` -------------------------------- ### Define Log Analytics Workspace Tables Schema Source: https://github.com/azure/terraform-azurerm-avm-res-operationalinsights-workspace/blob/main/README.md Use this to define custom tables within a Log Analytics Workspace. Specify table name, retention, plan, and schema details including columns with their names and types. ```hcl map(object({ name = string resource_id = optional(string) retention_in_days = optional(number) total_retention_in_days = optional(number) plan = optional(string) schema = optional(object({ name = optional(string) description = optional(string) columns = optional(list(object({ name = string type = string })), []) })) })) ``` -------------------------------- ### Terraform Configuration for Query Pack Deployment Source: https://github.com/azure/terraform-azurerm-avm-res-operationalinsights-workspace/blob/main/examples/deploy_query_packs/README.md This HCL code configures Terraform, providers, and modules to deploy an Azure Log Analytics Workspace and a Query Pack with a Monitor Query. It includes resource group creation and naming conventions. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = ">= 4.36.0, < 5.0.0" } random = { source = "hashicorp/random" version = ">= 3.5.0, < 4.0.0" } } } provider "azurerm" { features {} } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.1" } # This picks a random region from the list of regions. resource "random_integer" "region_index" { max = length(local.azure_regions) - 1 min = 0 } # This is required for resource modules resource "azurerm_resource_group" "rg" { location = local.azure_regions[random_integer.region_index.result] name = module.naming.resource_group.name_unique } # This is the module call module "log_analytics_workspace" { source = "../../" location = azurerm_resource_group.rg.location name = "thislaworkspace" resource_group_name = azurerm_resource_group.rg.name enable_telemetry = var.enable_telemetry log_analytics_workspace_identity = { type = "SystemAssigned" } log_analytics_workspace_retention_in_days = 30 log_analytics_workspace_sku = "PerGB2018" } module "query_packs" { source = "../../modules/query_packs" location = azurerm_resource_group.rg.location resource_group_id = azurerm_resource_group.rg.id monitor_queries = { "query1" = { query_pack_key = "pack1" display_name = "My Query" body = "Heartbeat | take 10" description = "Sample query" related = { categories = ["monitor"] } } } monitor_query_packs = { "pack1" = { name = "my-query-pack" tags = { env = "dev" } } } } ``` -------------------------------- ### Terraform Configuration for Log Analytics Workspace Source: https://github.com/azure/terraform-azurerm-avm-res-operationalinsights-workspace/blob/main/examples/default/README.md This HCL code defines the Terraform configuration, including required providers, resource group, and the Log Analytics Workspace module. It sets up basic parameters like location, name, and identity. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = ">= 4.36.0, < 5.0.0" } random = { source = "hashicorp/random" version = ">= 3.5.0, < 4.0.0" } } } provider "azurerm" { features {} #subscription_id = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.1" } # This picks a random region from the list of regions. resource "random_integer" "region_index" { max = length(local.azure_regions) - 1 min = 0 } # This is required for resource modules resource "azurerm_resource_group" "rg" { location = local.azure_regions[random_integer.region_index.result] name = module.naming.resource_group.name_unique } # This is the module call module "log_analytics_workspace" { source = "../../" location = azurerm_resource_group.rg.location name = "thislaworkspace" resource_group_name = azurerm_resource_group.rg.name # source = "Azure/avm-res-operationalinsights-workspace/azurerm" enable_telemetry = var.enable_telemetry log_analytics_workspace_identity = { type = "SystemAssigned" } log_analytics_workspace_retention_in_days = 30 log_analytics_workspace_sku = "PerGB2018" } ``` -------------------------------- ### Terraform Configuration for Security Insights Deployment Source: https://github.com/azure/terraform-azurerm-avm-res-operationalinsights-workspace/blob/main/examples/deploy_security_insights/README.md This HCL code configures Terraform, providers, and modules required to deploy Azure resources including a Log Analytics Workspace and Security Insights. It utilizes the AzureRM provider and a naming module for resource naming conventions. ```hcl terraform { required_version = ">= 1.3.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = ">= 4.36.0, < 5.0.0" } random = { source = "hashicorp/random" version = ">= 3.5.0, < 4.0.0" } } } provider "azurerm" { features {} #subscription_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.1" } # This picks a random region from the list of regions. resource "random_integer" "region_index" { max = length(local.azure_regions) - 1 min = 0 } # This is required for resource modules resource "azurerm_resource_group" "rg" { location = local.azure_regions[random_integer.region_index.result] name = module.naming.resource_group.name_unique } # This is the module call module "log_analytics_workspace" { source = "../../" location = azurerm_resource_group.rg.location name = "thislaworkspace" resource_group_name = azurerm_resource_group.rg.name # source = "Azure/avm-res-operationalinsights-workspace/azurerm" enable_telemetry = var.enable_telemetry log_analytics_workspace_identity = { type = "SystemAssigned" } log_analytics_workspace_retention_in_days = 30 log_analytics_workspace_sku = "PerGB2018" } module "log_analytics_solution" { source = "../../modules/log_analytics_solution" log_analytics_solution_location = azurerm_resource_group.rg.location log_analytics_solution_plan = { publisher = "Microsoft" product = "OMSGallery/SecurityInsights" } log_analytics_solution_resource_group_name = azurerm_resource_group.rg.name log_analytics_solution_solution_name = "SecurityInsights" log_analytics_solution_workspace_name = module.log_analytics_workspace.resource.name log_analytics_solution_workspace_resource_id = module.log_analytics_workspace.resource_id } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.