forked from HoussemDellai/azure-monitoring-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrafana.tf
More file actions
44 lines (36 loc) · 1.68 KB
/
Copy pathgrafana.tf
File metadata and controls
44 lines (36 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
resource "azurerm_dashboard_grafana" "grafana" {
name = "grafana-${var.prefix}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
api_key_enabled = true
deterministic_outbound_ip_enabled = true
public_network_access_enabled = true
sku = "Standard"
zone_redundancy_enabled = false
grafana_major_version = 11
identity {
type = "SystemAssigned"
}
}
# # might need : az extension add --name amg
# resource "terraform_data" "import-grafana-dashboard" {
# triggers_replace = [azurerm_dashboard_grafana.grafana.0.id]
# provisioner "local-exec" {
# command = "az grafana dashboard import -n ${azurerm_dashboard_grafana.grafana.0.name} -g ${azurerm_dashboard_grafana.grafana.0.resource_group_name} --definition 18814"
# }
# depends_on = [azurerm_role_assignment.role_grafana_admin]
# }
resource "azurerm_role_assignment" "role_grafana_admin" {
scope = azurerm_dashboard_grafana.grafana.id
role_definition_name = "Grafana Admin"
principal_id = data.azurerm_client_config.current.object_id
}
# https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/grafana-plugin
# to monitor all Azure resources
resource "azurerm_role_assignment" "role_monitoring_reader" {
scope = data.azurerm_subscription.subscription_spoke.id
role_definition_name = "Monitoring Reader"
principal_id = azurerm_dashboard_grafana.grafana.identity.0.principal_id
}
data "azurerm_client_config" "current" {}
data "azurerm_subscription" "subscription_spoke" {}