# Groups and resource access

A group brings people together within an [Avrea organization](/organizations/).
Groups form a tree. For example, an organization called Acme can have a
Platform group with a CI subgroup. Use the group path to identify the team
when two groups have the same name.

## Find a group with the CLI

[Install avr](/cli/#install) version 0.9.0 or later and sign in with your
own account; if this shell holds a service token in `AVR_TOKEN`, unset it
first. Replace `acme` with your organization slug.

```sh
avr auth device-login
avr group list --org acme
```

The list shows group paths such as `Acme/Platform/CI` and their IDs. The
default limit is 50. For a script, select the fields you need:

```sh
avr group list --org acme --limit 1000 --json group_id,path
```

See the [group command reference](/cli/reference/group/) for output options.
If Groups is unavailable for your organization, the CLI returns 404 and
the console shows **Settings > Members**. Once Groups is available, use
the console to manage the group tree and its membership.

## Create a group and add members

Creating a group needs group-management permission on its parent group,
which is the organization for a top-level group. Changing membership needs
member-management permission on the group and a recent sign-in.

1. Open **Settings > Members & Groups > Groups**.
2. Choose **New group** and name the team. To nest a group inside another,
   open the parent group's **⋯** menu and choose **Add sub-group**.
3. On the new group's **⋯** menu, choose **Manage members**, select people
   from the organization and choose **Apply changes**. To bring someone new
   into the organization, [invite them first](/organizations/#adding-members).

These steps apply to subgroups managed in Avrea. Manage root membership on
the organization's **Members** page and membership of synced groups in your
identity provider. Group membership and group administration are separate
assignments.

## What members can access

If resource access is not enabled for your organization, adding someone to
a group leaves their resource access unchanged. The **Manage members**
dialog says whether membership grants access.

Group membership also decides who can SSH into CI job VMs once an admin
[limits SSH to groups](/debugging/#limiting-ssh-to-groups), whether or not
resource access is enabled.

Once resource access is enabled, members receive grants from their group
and its ancestors while those groups are active. For example, a firewall rule shared with **Platform**
is also shared with members of **Platform/CI**. To share it with CI alone,
grant access on **Platform/CI** and check whether an ancestor already
grants it more broadly.

If you have permission to view a group's grants, open its **⋯** menu and
choose **Permissions, limits and suspensions > Resource access**. Members
with grant-management permission can also choose the resource and access
level there. For personal access to a GitHub repository, you still need
permission on GitHub.

## Give automation a service token

A service token belongs to a group, so it keeps working when its creator
leaves; its grants say what automation can read. An administrator with
token-management permission creates one with the group path from
`avr group list`. Replace the example organization, group and repository
with your own:

```sh
avr service-token create --org acme --group Acme/Platform/CI --name sbom-reader --repo acme/api --ttl 30d
```

Save the secret when it is shown. Follow [Read an SBOM from CI](/sbom/#read-an-sbom-from-ci)
to use it in the job.

If the console says service tokens are paused, wait for resource access to
be enabled before creating one. See [Access tokens](/access-tokens/#service-tokens)
for changing grants, rotating secrets and revoking tokens, or use the
[service-token command reference](/cli/reference/service-token/).