---
title: "IAM"
description: "The managed policies, resource names and actions for Fleets, and example policies for who may be which OS account on which nodes."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IAM

Fleets' actions are in the `fleets` namespace. Access is granted with [policies](/iam/policies),
attached directly or through groups, and checked on every request, so a change to a policy
applies to the next session, keepalive or run. API keys act with their owner's access.

## Managed policies

| Policy | Grants |
| --- | --- |
| `FleetsFullAccess` | Manage nodes, sessions, command runs, scripts and settings, and connect to nodes as any account |
| `FleetsReadOnlyAccess` | View nodes, sessions, command runs, scripts and settings |
| `FleetsManagedNodeAccess` | For a [node bot](/fleets/install-the-agent#create-a-node-bot): register machines and connect them to Fleets |

`ReadOnlyAccess` has every list and view action here. `AdministratorAccess` has everything.

## Resource names

| Resource | Pattern |
| --- | --- |
| Node | `…:prj_<project>:nod_<id>` |
| A node's OS account | `…:prj_<project>:nod_<id>/<account>` |
| Session | `…:prj_<project>:ssn_<id>` |
| Command run | `…:prj_<project>:cmd_<id>` |
| Script | `…:prj_<project>:scr_<id>` |

**Who may be whom** is decided on the node's account: `fleets.sessions.start`,
`fleets.commands.run` and `fleets.scripts.runOn` are checked on the node's name followed by
`/<account>`, such as `ezgh:us-west-1:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:nod_7m2k9q4x0a1b/root`.

| Pattern | Matches |
| --- | --- |
| `…:nod_*/ezgh-user` | `ezgh-user` on every node |
| `…:nod_*/root` | `root` on every node (not `rootx`) |
| `…:nod_7m2k9q4x0a1b/*` | Every account on one node |
| `…:prj_g7h8i9j0k1l2:*` | Everything in the project |

The bare node name (`…:nod_7m2k9q4x0a1b`) doesn't match account checks. That goes for denies too:
to deny every account on a node, deny `…:nod_7m2k9q4x0a1b/*` or `…:nod_7m2k9q4x0a1b*`, because a
deny on the bare name leaves its accounts allowed.

A node's tags aren't part of its name, so to treat production machines differently, keep them
in their own project.

## Examples

Everyone in a group may open a shell as `ezgh-user` on any node in the project:

```json
{
  "statements": [
    {
      "effect": "allow",
      "actions": ["fleets.nodes.list", "fleets.nodes.get"],
      "resources": ["ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2", "ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:nod_*"]
    },
    {
      "effect": "allow",
      "actions": ["fleets.sessions.start"],
      "resources": ["ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:nod_*/ezgh-user"]
    }
  ]
}
```

The SRE group may also be `root` on every node:

```json
{
  "statements": [
    {
      "effect": "allow",
      "actions": ["fleets.sessions.start", "fleets.commands.run"],
      "resources": ["ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:nod_*/root"]
    }
  ]
}
```

On-call may run the saved script `restart-service` as `root` on any node, but no other command or
script:

```json
{
  "statements": [
    {
      "effect": "allow",
      "actions": ["fleets.scripts.run"],
      "resources": ["ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:scr_4h8k2m9x0a1b"]
    },
    {
      "effect": "allow",
      "actions": ["fleets.scripts.runOn"],
      "resources": ["ezgh:*:org_k3f9a0x2m7qp:prj_g7h8i9j0k1l2:nod_*/root"]
    }
  ]
}
```

## Actions

| Action | Allows | Checked against | Managed policies |
| --- | --- | --- | --- |
| `fleets.nodes.register` | Register a machine as a node | The project | `FleetsFullAccess`, `FleetsManagedNodeAccess` |
| `fleets.nodes.connect` | Connect a node's agent | The node | `FleetsFullAccess`, `FleetsManagedNodeAccess` |
| `fleets.nodes.list` | List nodes | The project | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.nodes.get` | View a node | The node | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.nodes.update` | Rename a node or change its tags | The node | `FleetsFullAccess` |
| `fleets.nodes.reset` | Reset a node's registration | The node | `FleetsFullAccess` |
| `fleets.nodes.deregister` | Deregister a node | The node | `FleetsFullAccess` |
| `fleets.sessions.start` | Start or resume a session as an account | The node's account | `FleetsFullAccess` |
| `fleets.sessions.list` | List live sessions | The project | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.sessions.get` | View a live session | The session | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.sessions.terminate` | Terminate a session | The session | `FleetsFullAccess` |
| `fleets.commands.run` | Run a command as an account | Each target node's account | `FleetsFullAccess` |
| `fleets.commands.list` | List command runs | The project | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.commands.get` | View a command run and its invocations | The command run | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.commands.cancel` | Cancel a command run | The command run | `FleetsFullAccess` |
| `fleets.scripts.run` | Run a script | The script | `FleetsFullAccess` |
| `fleets.scripts.runOn` | Run a script as an account | Each target node's account | `FleetsFullAccess` |
| `fleets.scripts.create` | Create scripts | The project | `FleetsFullAccess` |
| `fleets.scripts.list` | List scripts | The project | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.scripts.get` | View a script and its versions | The script | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.scripts.update` | Change a script or add a version | The script | `FleetsFullAccess` |
| `fleets.scripts.delete` | Delete a script | The script | `FleetsFullAccess` |
| `fleets.settings.get` | View a project's Fleets settings | The project | `ReadOnlyAccess`, `FleetsFullAccess`, `FleetsReadOnlyAccess` |
| `fleets.settings.update` | Change a project's Fleets settings | The project | `FleetsFullAccess` |

While you're connected, your access is checked again every 2 minutes, with `fleets.sessions.start`,
and a denial ends the session with reason `revoked`. A command
run is checked once, when it's created; cancel it to stop it.

Source: https://docs.ezghcloud.com/fleets/iam/index.mdx
