You grant access to Google Cloud Managed Lustre operations by granting
Identity and Access Management (IAM) roles to users.

IAM permissions only control access to Google Cloud Managed Lustre operations, like
creating a Google Cloud Managed Lustre instance. To control access to file system
operations on the instance, like reading or writing to a file, use POSIX file
permissions.

## Permissions and roles

Managed Lustre uses the following permissions:

| Permission | Description |
|---|---|
| `lustre.instances.create` | Create new instances |
| `lustre.instances.delete` | Delete instances |
| `lustre.instances.update` | Update instances. Does not allow deletion |
| `lustre.instances.get` | Describe instances |
| `lustre.instances.list` | List all instances |
| `lustre.instances.exportData` | Export data from Managed Lustre to Cloud Storage |
| `lustre.instances.importData` | Import data from Cloud Storage to Managed Lustre |
| `lustre.locations.get` | Get a location |
| `lustre.locations.list` | List all supported locations |
| `lustre.mirrors.create` | Create new mirrors |
| `lustre.mirrors.delete` | Delete mirrors |
| `lustre.mirrors.update` | Update mirrors |
| `lustre.mirrors.get` | Describe mirrors |
| `lustre.mirrors.list` | List mirrors |
| `lustre.operations.list` | List operations |
| `lustre.operations.get` | Get an operation |
| `lustre.operations.cancel` | Cancel an operation |
| `lustre.operations.delete` | Delete an operation |

Google Cloud doesn't support granting individual permissions directly; you must
grant a role that contains permissions. Managed Lustre's
predefined roles are:

- Managed Lustre Admin (`roles/lustre.admin`)
- Managed Lustre Viewer (`roles/lustre.viewer`)

The following table lists the
permissions granted by the predefined roles for Managed Lustre,
as well as the [basic Editor role](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#basic):

| Capability | Editor (`roles/editor`) | Managed Lustre (`roles/lustre.*`) ||
| Capability | Editor (`roles/editor`) | Admin (`roles/lustre.admin`) | Viewer (`roles/lustre.viewer`) |
|---|---|---|---|
| Create instances | Yes | Yes | No |
| Delete instances | Yes | Yes | No |
| Update instances | Yes | Yes | No |
| Get instances | Yes | Yes | Yes |
| List instances | Yes | Yes | Yes |
| Import/export data from/to Cloud Storage | Yes | Yes | No |
| Configure a Cloud Storage mirror | Yes | Yes | No |
| Get a location | Yes | Yes | Yes |
| List supported locations | Yes | Yes | Yes |
| List long-running operations | Yes | Yes | Yes |
| Get an operation | Yes | Yes | Yes |
| Cancel an operation | Yes | Yes | No |
| Delete an operation | Yes | Yes | No |

## Custom roles

If the available predefined roles don't meet your organization's access
requirements, you can create
and apply [custom IAM roles](https://docs.cloud.google.com/iam/docs/understanding-custom-roles).

When creating custom roles, we recommend using a combination of predefined
roles to ensure that the correct permissions are included together.

## Managed Lustre service agent

Managed Lustre uses a [service agent](https://docs.cloud.google.com/iam/docs/service-agents.md.txt)
to access other Google Cloud resources and perform actions on your behalf. A
service agent is a Google-managed service account that is automatically created
the first time you create a Managed Lustre instance in a
project. It can also be manually created.

Granting permissions to the service agent is only required if you use certain
optional features. For standard instance creation and file system operations
without these features, no service agent configuration is needed.

### Features that require service agent permissions

The following features require granting IAM roles to the service agent:

| Feature | Required role | Target resource | Description |
|---|---|---|---|
| [Customer-managed encryption keys (CMEK)](https://docs.cloud.google.com/managed-lustre/docs/cmek.md.txt) | `roles/cloudkms.cryptoKeyEncrypterDecrypter` | Cloud KMS key | Allows the service agent to encrypt and decrypt data at rest using your key. |
| [Cloud Storage mirror](https://docs.cloud.google.com/managed-lustre/docs/storage-mirror.md.txt) | Custom role granting `storage.buckets.get`, `storage.buckets.update`, `storage.objects.get`, and `storage.objects.list` | Cloud Storage bucket | Allows the service agent to create Pub/Sub notifications and mirror objects from the bucket into the instance. |
| [Transfer data from Cloud Storage](https://docs.cloud.google.com/managed-lustre/docs/transfer-data.md.txt) | `roles/storage.objectViewer` | Cloud Storage bucket | Allows the service agent to read and import objects from your bucket into the instance. |
| [Transfer data to and from Cloud Storage](https://docs.cloud.google.com/managed-lustre/docs/transfer-data.md.txt) | `roles/storage.objectUser` | Cloud Storage bucket | Allows the service agent to read and write objects during import and export operations. |

If you are not using any of these features, you can skip the remaining steps in
this section.

### Create or retrieve the service agent identity

To grant permissions to the service agent, you must obtain its identity. The
service agent uses the following format:

    service-PROJECT_NUMBER@gcp-sa-lustre.iam.gserviceaccount.com

Use one of the following options to create or determine the service agent
identity:

- **If you have not created a Managed Lustre instance:**
  Create the service agent manually by running the
  [`services identity create`](https://docs.cloud.google.com/sdk/gcloud/reference/beta/services/identity/create.md.txt)
  command:

  ```bash
  gcloud beta services identity create \
    --service=lustre.googleapis.com \
    --project=PROJECT_NUMBER_OR_ID
  ```

  Replace <var translate="no">PROJECT_NUMBER_OR_ID</var> with the project number or ID of the
  project where you want to create the Managed Lustre instance.
  The command returns output similar to the following:

      Service identity created: service-1234567890@gcp-sa-lustre.iam.gserviceaccount.com

- **If you have already created a Managed Lustre instance:**
  To construct the service agent identity, retrieve your project number using
  the `gcloud projects describe` command:

  ```bash
  gcloud projects describe PROJECT_ID --format="value(projectNumber)"
  ```

  Replace <var translate="no">PROJECT_ID</var> with your project ID. Then, substitute
  <var translate="no">PROJECT_NUMBER</var> in the service agent email address:

      service-PROJECT_NUMBER@gcp-sa-lustre.iam.gserviceaccount.com

### Grant permissions to the service agent

After obtaining your service agent identity, see the following documentation to
grant the required role for your feature:

- [Customer-managed encryption keys (CMEK)](https://docs.cloud.google.com/managed-lustre/docs/cmek.md.txt#grant-permissions)
- [Transfer data to and from Cloud Storage](https://docs.cloud.google.com/managed-lustre/docs/transfer-data.md.txt#grant-permissions)
- [Cloud Storage mirror](https://docs.cloud.google.com/managed-lustre/docs/storage-mirror.md.txt#grant-sa-permissions)

## Additional required Google Cloud permissions

In addition to `lustre` permissions, you might require permissions in other
Google Cloud services to perform specific tasks:

| Task | Permission |
|---|---|
| Create a VPC network | See the *Required permissions* section of [Configure a VPC network](https://docs.cloud.google.com/managed-lustre/docs/vpc.md.txt#iam) |
| Create Compute Engine VMs | Compute Instance Admin (v1). (`roles/compute.instanceAdmin.v1`) For more information, refer to the [Compute Engine documentation](https://docs.cloud.google.com/compute/docs/instances/create-start-instance.md.txt#required-roles). |
| Create and manage Google Kubernetes Engine clusters | Container Admin. (`roles/container.admin`) For more information, refer to the [Google Kubernetes Engine documentation](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/iam.md.txt#predefined). |