Create dashboard folders with team permissions and import dashboards

Creating dashboard folders with team permissions organizes your dashboards and ensures teams only see dashboards relevant to their work. This implements the least privilege principle by removing default viewer access.

In this example, you’ll create three different folders and import the files financedash.json, marketingdash.json, and itdash.json to their corresponding folders.

To create dashboard folders with team permissions and import dashboards, complete the following steps:

  1. Create a file named apply_folder_permissions.tf:

    hcl
    resource "grafana_folder" "finance" {
      title = "Finance"
    }
    
    resource "grafana_folder" "marketing" {
      title = "Marketing"
    }
    
    resource "grafana_folder" "it" {
      title = "IT"
    }
  2. Add dashboard imports to the same file:

    hcl
    resource "grafana_dashboard" "finance_kpis" {
      folder      = grafana_folder.finance.id
      config_json = file("${path.module}/financedash.json")
    }
    
    resource "grafana_dashboard" "marketing_tracking" {
      folder      = grafana_folder.marketing.id
      config_json = file("${path.module}/marketingdash.json")
    }
    
    resource "grafana_dashboard" "it_operations" {
      folder      = grafana_folder.it.id
      config_json = file("${path.module}/itdash.json")
    }
  3. Add folder permissions with least privilege access:

    hcl
    resource "grafana_folder_permission" "finance" {
      folder_uid = grafana_folder.finance.uid
    
      permissions {
        team_id    = grafana_team.finance.id
        permission = "Admin"
      }
    }
    
    resource "grafana_folder_permission" "marketing" {
      folder_uid = grafana_folder.marketing.uid
    
      permissions {
        team_id    = grafana_team.marketing.id
        permission = "Admin"
      }
    }
  4. Apply the configuration:

    sh
    terraform apply

The folders are created with imported dashboards, and only the assigned teams can access their respective folders.

In the next milestone, you’ll configure alert rules and notification policies.


page 8 of 12