Hi everyone,
First off, thanks in advance for taking the time to read through this! I really appreciate it.
I’m experiencing an issue with azurerm_monitor_log_profile. I have two .tf files, zonea.tf and zoneb.tf. Zone A and Zone B are separate Azure subscriptions. I’ve plugged Terraform into Zone B by specifying the below for each resource:
provider = “azurerm.b”
Strangely, the insights-operational-logs instance gets created in Zone B, but in Zone A, it doesn’t and I receive the message:
Error: Error Creating/Updating Log Profile “activity_log-a”: insights.LogProfilesClient#CreateOrUpdate: Failure sending request: StatusCode=409 – Original Error: autorest/azure: Service returned an error. Status=
on zonea.tf line 329, in resource “azurerm_monitor_log_profile” “activity_log-a”:
329: resource “azurerm_monitor_log_profile” “activity_log-a” {
I’m not really sure why the log instance isn’t being created in Zone A. The code looks right to me, and I’d think that it’s proof that it’s correct because the resource is provisioned correctly in Zone B.
Just for reference, here is the code I’m using for each zone. Please let me know if you can spot anything that I might be doing wrong. I really do appreciate the help!
For Zone A:
resource “azurerm_storage_account” “zoneastorageaccount” {
name = “zoneastorageaccount”
location = “{azurerm_resource_group.rgSharedResources-A.location}"
resource_group_name = "{azurerm_resource_group.rgSharedResources-A.name}”
account_tier = “Standard”
account_replication_type = “LRS”
}
resource “azurerm_eventhub_namespace” “zonealogprofileeventhub” {
name = “zonealogprofileeventhub”
location = “{azurerm_resource_group.rgSharedResources-A.location}"
resource_group_name = "{azurerm_resource_group.rgSharedResources-A.name}”
sku = “Standard”
capacity = 2
}
resource “azurerm_monitor_log_profile” “activity_log-a” {
name = “activity_log-a”
categories = [
“Action”,
“Delete”,
“Write”,
]
locations = [
“${var.location}”,
“global”,
]
servicebus_rule_id = "${azurerm_eventhub_namespace.zonealogprofileeventhub.id}/authorizationrules/RootManageSharedAccessKey"
storage_account_id = "${azurerm_storage_account.zoneastorageaccount.id}"
retention_policy {
enabled = true
days = 7
}
}
For Zone B:
resource “azurerm_storage_account” “zonebstorageaccount” {
provider = “azurerm.b”
name = “zonebstorageaccount”
location = “{azurerm_resource_group.rgSharedResources-B.location}"
resource_group_name = "{azurerm_resource_group.rgSharedResources-B.name}”
account_tier = “Standard”
account_replication_type = “LRS”
}
resource “azurerm_eventhub_namespace” “zoneblogprofileeventhub” {
provider = “azurerm.b”
name = “zoneblogprofileeventhub”
location = “{azurerm_resource_group.rgSharedResources-B.location}"
resource_group_name = "{azurerm_resource_group.rgSharedResources-B.name}”
sku = “Standard”
capacity = 2
}
resource “azurerm_monitor_log_profile” “activity_log-B” {
provider = “azurerm.b”
name = “activity_log”
categories = [
“Action”,
“Delete”,
“Write”,
]
locations = [
“${var.location}”,
“global”,
]
servicebus_rule_id = "${azurerm_eventhub_namespace.zoneblogprofileeventhub.id}/authorizationrules/RootManageSharedAccessKey"
storage_account_id = "${azurerm_storage_account.zonebstorageaccount.id}"
retention_policy {
enabled = true
days = 7
}
}