Skip to content

Commit 7932182

Browse files
authored
Add a shared dashboard module (#261)
We would like to setup a dashboard on the Azure portal for our different environments on the Invite team. This would allow repos to pass in a template file as the dashboard_properties, e.g: ``` dashboard_properties = templatefile("dashboard-template.tpl", { environment = var.environment sub_id = var.hub_subscription_id } ) ``` https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/portal_dashboard
1 parent 57340c6 commit 7932182

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# app-insights
2+
3+
## Terraform documentation
4+
For the list of inputs, outputs, resources... check the [terraform module documentation](tfdocs.md).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "azurerm_portal_dashboard" "dashboard" {
2+
3+
name = var.name
4+
location = var.location
5+
resource_group_name = var.resource_group_name
6+
tags = var.tags
7+
8+
dashboard_properties = var.dashboard_properties
9+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Module documentation
2+
3+
## Required Inputs
4+
5+
The following input variables are required:
6+
7+
### <a name="input_location"></a> [location](#input\_location)
8+
9+
Description: The location/region where the dashboard is created.
10+
11+
Type: `string`
12+
13+
### <a name="input_name"></a> [name](#input\_name)
14+
15+
Description: Is the dashboard workspace name.
16+
17+
Type: `string`
18+
19+
### <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name)
20+
21+
Description: The name of the resource group in which the Dashboard is created. Changing this forces a new resource to be created.
22+
23+
Type: `string`
24+
25+
## Optional Inputs
26+
27+
The following input variables are optional (have default values):
28+
29+
### <a name="input_dashboard_properties"></a> [dashboard\_properties](#input\_dashboard\_properties)
30+
31+
Description: JSON data representing dashboard body. See above for details on how to obtain this from the Portal.
32+
33+
Type: `string`
34+
35+
Default: `{}`
36+
37+
### <a name="input_tags"></a> [tags](#input\_tags)
38+
39+
Description: A mapping of tags to assign to the resource.
40+
41+
Type: `map(string)`
42+
43+
Default: `{}`
44+
45+
46+
## Resources
47+
48+
The following resources are used by this module:
49+
50+
- [azurerm_portal_dashboard.dashboard](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/portal_dashboard) (resource)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
variable "location" {
2+
type = string
3+
description = "The location/region where the dashboard is created."
4+
}
5+
6+
variable "name" {
7+
description = "Is the dashboard workspace name."
8+
type = string
9+
validation {
10+
condition = can(regex("^[a-zA-Z0-9][a-zA-Z0-9-_]{0,253}[a-zA-Z0-9]$", var.name))
11+
error_message = "The Dashboard name must be between 1 and 255 characters, start and end with an alphanumeric character, and can contain alphanumeric characters, hyphens, periods, and underscores (but not at the start or end)."
12+
}
13+
}
14+
15+
variable "resource_group_name" {
16+
type = string
17+
description = "The name of the resource group in which the Dashboard is created. Changing this forces a new resource to be created."
18+
}
19+
20+
variable "tags" {
21+
type = map(string)
22+
default = {}
23+
description = "A mapping of tags to assign to the resource."
24+
}
25+
26+
variable "dashboard_properties" {
27+
type = string
28+
default = {}
29+
description = "JSON data representing dashboard body. See above for details on how to obtain this from the Portal."
30+
}

infrastructure/modules/shared-config/output.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ locals {
6464
container-app-environment = lower("CAE-${var.env}-${var.location_map[var.location]}-${var.application}")
6565
connection = lower("CON-${var.env}-${var.location_map[var.location]}-${var.application}")
6666
custom-image = lower("IMAGE-${var.env}-${var.location_map[var.location]}")
67+
dashboard = lower("DASH-${var.env}-${var.location_map[var.location]}-${var.application}")
6768
dev-center = lower("DEVC-${var.env}-${var.location_map[var.location]}")
6869
dev-center-project = lower("prj-${var.env}-${var.location_map[var.location]}")
6970
dns-zone = lower("${var.application}.${var.env}.net")

0 commit comments

Comments
 (0)