azurerm_log_analytics_workspace
azurerm_kubernetes_cluster
resource "azurerm_resource_group" "example" {
name = "example"
location = "West Europe"
}
resource "azurerm_kubernetes_cluster" "example" {
name = "example"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
dns_prefix = "example"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
identity {
type = "SystemAssigned"
}
addon_profile {
oms_agent {
enabled = true
log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
}
kube_dashboard {
enabled = true
}
}
}
resource "azurerm_log_analytics_workspace" "example" {
name = "example"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "PerGB2018"
retention_in_days = 30
}
provider "azurerm" {
features {}
version = "2.25.0"
}
terraform apply
...
oms_agent {
enabled = false
}
...
terraform apply
...
oms_agent {
enabled = true
log_analytics_workspace_id = azurerm_log_analytics_workspace.example.id
}
...
terraform apply
terraform apply
The last terraform apply
in step 6 should show no changes.
Terraform wants to add the LAW id in step 6.
...
~ addon_profile {
~ oms_agent {
enabled = true
+ log_analytics_workspace_id = "/subscriptions/***..."
...
Applying the change doesn't help. The same change will be shown on the next plan/apply.
We checked the Azure Portal and API and the LAW is correctly connected.
The terraform state looks like this:
...
"enabled": true,
"log_analytics_workspace_id": "",
...
We also tried to manually add the id in the state, but the plan still wants to add it again.
Removing and re-importing the azurerm_kubernetes_cluster resource doesn't help either.
After debugging the plan, we confirmed that the Azure API returns the LAW id correctly:
...
"omsagent": {
"enabled": true,
"config": {
"loganalyticsworkspaceresourceid": "/subscriptions/***...."
},
...
@muellermatthias Thank you for letting us know this issue!
This is actually an Azure issue, to which I have opened an issue against. In the meanwhile, I opened another PR to side walk this issue in provider. Once it is merged, you should be unblocked :+1:
Since the fix for this from the Azure Provider's side has been merged in #8374 I'm going to close this issue for the moment - however the upstream bug in the Azure API tracking this is here: https://github.com/Azure/azure-rest-api-specs/issues/10716
This has been released in version 2.28.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:
provider "azurerm" {
version = "~> 2.28.0"
}
# ... other configuration ...
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
@muellermatthias Thank you for letting us know this issue!
This is actually an Azure issue, to which I have opened an issue against. In the meanwhile, I opened another PR to side walk this issue in provider. Once it is merged, you should be unblocked :+1: