Skip to content

Commit

Permalink
88 works
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussemDellai committed Mar 5, 2024
1 parent 048db3f commit 3fac931
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 0 additions & 2 deletions 88_prometheus_grafana_ampls/aks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
}
}
29 changes: 28 additions & 1 deletion 88_prometheus_grafana_ampls/grafana-mpe.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
})
}

0 comments on commit 3fac931

Please sign in to comment.