---
title: "Create teams with external group sync | Grafana Labs"
description: "Define teams in Terraform and link them to identity provider groups for automated user access."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Create teams with external group sync

Creating teams with external group synchronization automates user access management. When users sign in through your identity provider, they’re automatically added to the appropriate Grafana teams based on their group memberships.

To create teams with external group sync, complete the following steps:

1. Create a file named `teams.tf` in your Terraform directory.
2. Add the team definitions with external group mappings:
   
   hcl ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```hcl
   resource "grafana_team" "finance" {
     name = "Finance"
   
     team_sync {
       groups = ["Finance"]
     }
   }
   
   resource "grafana_team" "marketing" {
     name = "Marketing"
   
     team_sync {
       groups = ["Marketing"]
     }
   }
   
   resource "grafana_team" "it" {
     name = "IT"
   
     team_sync {
       groups = ["IT"]
     }
   }
   ```
3. Apply the configuration:
   
   sh ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```sh
   terraform apply
   ```
4. When prompted, type `yes` to confirm the changes.

The teams are created and configured to sync with your identity provider groups. Users in these groups are automatically added to the corresponding Grafana teams when they sign in.

In the next milestone, you’ll implement custom RBAC roles and label-based access controls.
