Skip to content

mwimpelberg28/grafana-rbac-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Grafana RBAC/LBAC Demo

A comprehensive demonstration of Role-Based Access Control (RBAC) implementation in Grafana Cloud using Terraform. This project showcases enterprise-grade team management, SSO integration, and granular permission controls across development and production environments.

🎯 Purpose

This demo illustrates how to implement:

  • Multi-environment Grafana Cloud infrastructure (dev/prod)
  • Team-based access controls with granular permissions
  • SSO integration with Okta for enterprise authentication
  • Label-Based Access Control (LBAC) for data source security

πŸ—οΈ Architecture Overview

grafana-rbac-demo/
β”œβ”€β”€ dev/                    # Development environment
β”‚   β”œβ”€β”€ provider.tf         # Grafana Cloud provider configuration
β”‚   β”œβ”€β”€ variables.tf        # Input variables definition
β”‚   β”œβ”€β”€ terraform.tfvars    # Development-specific values
β”‚   β”œβ”€β”€ stack.tf           # Grafana Cloud stack creation
β”‚   β”œβ”€β”€ auth.tf            # Okta SSO configuration
β”‚   β”œβ”€β”€ teams.tf           # Team creation and sync
β”‚   β”œβ”€β”€ roles.tf           # RBAC role assignments
β”‚   β”œβ”€β”€ folders.tf         # Dashboard folders and permissions
β”‚   └── datasource.tf      # Data source configuration and LBAC
β”œβ”€β”€ prod/                  # Production environment
β”‚   └── [similar structure with prod-specific configs]
β”œβ”€β”€ .gitignore            # Terraform-specific ignore patterns
└── README.md             # This file

πŸ”§ Prerequisites

  • Grafana Cloud account with appropriate permissions
  • Okta developer account for SSO integration

πŸš€ Quick Start

1. Clone the Repository

git clone <repository-url>
cd grafana-rbac-demo

2. Configure Variables

Create or update terraform.tfvars files for each environment with your specific values:

Development Environment

cd dev/

Update terraform.tfvars with your configuration:

grafana_cloud_access_policy_token = "your_grafana_cloud_token"
okta_auth_url                    = "https://your-org.okta.com/oauth2/v1/authorize"
okta_token_url                   = "https://your-org.okta.com/oauth2/v1/token"
okta_api_url                     = "https://your-org.okta.com/oauth2/v1/userinfo"
okta_client_id                   = "your_okta_client_id"
okta_client_secret               = "your_okta_client_secret"
loki_datasource_name             = "your_loki_datasource_name"
stack_name                       = "your_dev_stack_name"
stack_description                = "Development Stack"

Update providers.tf to the URL of your stack

provider "grafana" {
  alias = "dev"
  url   = "https://<your_stack>.grafana.net"
  auth  = grafana_cloud_stack_service_account_token.cloud_sa_token.key
}

3. Deploy Infrastructure

Deploy Development Environment

cd dev/
terraform init
terraform plan
terraform apply

Deploy Production Environment

cd ../prod/
terraform init
terraform plan
terraform apply

πŸ” Security & Access Control Features

Team Structure

  • Admins Team: Full administrative access across all resources
  • Dev Team A: Scoped access to Team A resources and data
  • Dev Team B: Scoped access to Team B resources and data

Role-Based Permissions

Development Teams (Team A & Team B)

  • Dashboard creation and editing within assigned folders
  • Data source exploration and querying
  • Alerting rule management
  • Library panel creation and sharing
  • Folder-specific administrative access

Admin Team

  • All development team permissions
  • Organization and user management
  • Team management capabilities
  • Data source administration
  • System-wide configuration access

Label-Based Access Control (LBAC)

  • Team A: Access restricted to logs matching { app = "a" }
  • Team B: Access restricted to logs matching { app = "b" }
  • Automatic data filtering based on team membership
  • Prevents cross-team data access

SSO Integration

  • Okta OAuth2 authentication
  • Automatic team synchronization based on Okta groups
  • Role mapping from Okta to Grafana teams
  • Just-in-time provisioning of users

πŸ“ Key Components

Infrastructure Components

Component Purpose Key Features
Stack Grafana Cloud instance Multi-region support, service accounts
Auth SSO configuration Okta integration, role mapping
Teams Organizational structure Group sync, team isolation
Roles Permission management Granular RBAC using fixed roles
Folders Dashboard organization Team-specific access controls
Data Sources Log aggregation LBAC rules, secure access policies

Variable Configuration

All sensitive and environment-specific values are externalized into variables:

  • Authentication tokens and secrets
  • Okta configuration parameters
  • Stack naming and descriptions
  • Data source configurations
  • URL endpoints for different environments

State Management

  • Local state for demo purposes
  • Separate state per environment
  • Gitignored state files for security

Implemented in This Demo

  • βœ… Secrets externalization via variables
  • βœ… Least privilege access using specific roles
  • βœ… Data isolation through LBAC rules
  • βœ… SSO integration for centralized authentication
  • βœ… Team-based segregation of resources

Production Recommendations

  • πŸ” Use secret management (HashiCorp Vault, AWS Secrets Manager)
  • πŸ” Enable remote state with encryption
  • πŸ” Implement CI/CD with proper approval workflows
  • πŸ” Regular access reviews and permission audits
  • πŸ” Monitor and alert on configuration changes

πŸ“š References

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Test changes in development environment
  4. Update documentation as needed
  5. Submit a pull request with detailed description

πŸ“„ License

This project is licensed under the terms specified in the LICENSE file.


⚠️ Security Notice: This demo contains example credentials and tokens. Never use these values in production environments. Always generate your own secure credentials and follow proper secret management practices.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages