dependency/azapi_examples/Microsoft.Insights_diagnosticSettings@2021-05-01-preview/main.tf (128 lines of code) (raw):

terraform { required_providers { azapi = { source = "Azure/azapi" } azurerm = { source = "hashicorp/azurerm" } } } provider "azurerm" { features { } } provider "azapi" { skip_provider_registration = false } variable "resource_name" { type = string default = "acctest0001" } variable "location" { type = string default = "westeurope" } data "azurerm_client_config" "current" { } resource "azapi_resource" "resourceGroup" { type = "Microsoft.Resources/resourceGroups@2020-06-01" name = var.resource_name location = var.location } resource "azapi_resource" "vault" { type = "Microsoft.KeyVault/vaults@2021-10-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { accessPolicies = [ ] createMode = "default" enableRbacAuthorization = false enableSoftDelete = true enabledForDeployment = false enabledForDiskEncryption = false enabledForTemplateDeployment = false publicNetworkAccess = "Enabled" sku = { family = "A" name = "standard" } tenantId = data.azurerm_client_config.current.tenant_id } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "namespace" { type = "Microsoft.EventHub/namespaces@2022-01-01-preview" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { disableLocalAuth = false isAutoInflateEnabled = false publicNetworkAccess = "Enabled" zoneRedundant = false } sku = { capacity = 1 name = "Basic" tier = "Basic" } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "authorizationRule" { type = "Microsoft.EventHub/namespaces/authorizationRules@2021-11-01" parent_id = azapi_resource.namespace.id name = "example" body = { properties = { rights = [ "Listen", "Send", "Manage", ] } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "diagnosticSetting" { type = "Microsoft.Insights/diagnosticSettings@2021-05-01-preview" parent_id = azapi_resource.vault.id name = var.resource_name body = { properties = { eventHubAuthorizationRuleId = azapi_resource.authorizationRule.id eventHubName = azapi_resource.namespace.name logs = [ { categoryGroup = "Audit" enabled = true retentionPolicy = { days = 0 enabled = false } }, ] metrics = [ { category = "AllMetrics" enabled = true retentionPolicy = { days = 0 enabled = false } }, ] } } schema_validation_enabled = false response_export_values = ["*"] }