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.
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
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
- Grafana Cloud account with appropriate permissions
- Okta developer account for SSO integration
git clone <repository-url>
cd grafana-rbac-demoCreate or update terraform.tfvars files for each environment with your specific values:
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
}cd dev/
terraform init
terraform plan
terraform applycd ../prod/
terraform init
terraform plan
terraform apply- 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
- Dashboard creation and editing within assigned folders
- Data source exploration and querying
- Alerting rule management
- Library panel creation and sharing
- Folder-specific administrative access
- All development team permissions
- Organization and user management
- Team management capabilities
- Data source administration
- System-wide configuration access
- 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
- Okta OAuth2 authentication
- Automatic team synchronization based on Okta groups
- Role mapping from Okta to Grafana teams
- Just-in-time provisioning of users
| 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 |
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
- Local state for demo purposes
- Separate state per environment
- Gitignored state files for security
- β 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
- π 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
- Grafana RBAC Documentation
- Grafana Terraform Provider
- Okta OAuth2 Integration
- Terraform Best Practices
- Fork the repository
- Create a feature branch
- Test changes in development environment
- Update documentation as needed
- Submit a pull request with detailed description
This project is licensed under the terms specified in the LICENSE file.