diff --git a/88_prometheus_grafana_ampls/aks.tf b/88_prometheus_grafana_ampls/aks.tf index a1aa1ca..62573bd 100644 --- a/88_prometheus_grafana_ampls/aks.tf +++ b/88_prometheus_grafana_ampls/aks.tf @@ -35,9 +35,7 @@ resource "azurerm_kubernetes_cluster" "aks" { lifecycle { ignore_changes = [ - # monitor_metrics, default_node_pool.0.upgrade_settings, - # default_node_pool.0.upgrade_settings.0.max_surge, ] } } diff --git a/88_prometheus_grafana_ampls/diagnostic_setting.tf b/88_prometheus_grafana_ampls/apps/diagnostic_setting.tf similarity index 100% rename from 88_prometheus_grafana_ampls/diagnostic_setting.tf rename to 88_prometheus_grafana_ampls/apps/diagnostic_setting.tf diff --git a/88_prometheus_grafana_ampls/grafana-mpe.tf b/88_prometheus_grafana_ampls/grafana-mpe.tf index a5a0b0b..f932234 100644 --- a/88_prometheus_grafana_ampls/grafana-mpe.tf +++ b/88_prometheus_grafana_ampls/grafana-mpe.tf @@ -10,8 +10,35 @@ resource "azapi_resource" "mpe-grafana" { properties = { privateLinkResourceId : azurerm_monitor_workspace.prometheus.id, privateLinkResourceRegion : azurerm_dashboard_grafana.grafana.location, - groupIds : [ "prometheusMetrics" ], + groupIds : ["prometheusMetrics"], requestMessage : "Please approve for Grafana to connect to Prometheus" } }) } + +# Retrieve the Managed Private Endpoints (MPE) +data "azapi_resource_list" "mpe-grafana" { + type = "Microsoft.Monitor/accounts/privateEndpointConnections@2023-04-03" + parent_id = azurerm_monitor_workspace.prometheus.id + response_export_values = ["*"] +} + +# Retrieve the Grafana's Managed Private Endpoint ID +locals { + mpe-grafana-id = element([for pe in jsondecode(data.azapi_resource_list.mpe-grafana.output).value : pe.id if strcontains(pe.id, azapi_resource.mpe-grafana.name)], 0) +} + +# Approve Grafana's Managed Private Endpoint connection to Prometheus +resource "azapi_update_resource" "approve-mpe-grafana" { + type = "Microsoft.Monitor/accounts/privateEndpointConnections@2023-04-03" + resource_id = local.mpe-grafana-id + + body = jsonencode({ + properties = { + privateLinkServiceConnectionState = { + status : "Approved" + description : "Approved by Terraform" + } + } + }) +}