This page describes how to grant a Google Cloud user account or service
account access to basic Dataproc Metastore resources in a project. These roles described on this page provide access to create a Dataproc Metastore service.

Depending on the scope of control you want the account to have, you grant it one of these predefined IAM roles:

- `roles/metastore.editor` to grant full control of Dataproc Metastore resources
- `roles/metastore.admin` to grant full control of Dataproc Metastore resources, including updating IAM permissions.

For detailed information about the specific IAM permissions these roles provide, see [Dataproc Metastore IAM roles](https://docs.cloud.google.com/dataproc-metastore/docs/iam-roles).

> [!NOTE]
> **Note:** Completing other actions with your metastore---such as importing MySQL files---requires you to add extra roles that are not detailed on this page. You can find more information about these roles in the respective feature guides.

## Before you begin

<br />

### Required Roles

You must have the `roles/owner` (Owner) basic IAM role in the
Google Cloud project you are using, or a role that grants these permissions:

- `resourcemanager.projects.get`
- `resourcemanager.projects.getIamPolicy`
- `resourcemanager.projects.setIamPolicy`

To gain these permissions while following the principle of least privilege,
ask your administrator to grant you the `roles/resourcemanager.projectIamAdmin` (Project IAM Admin)
role.

## How to grant access roles

### gcloud

To use the gcloud CLI, you can [install and initialize](https://cloud.google.com/sdk/docs/install) the Google Cloud CLI, or you can use [Cloud Shell](https://cloud.google.com/shell/docs/using-cloud-shell).

Run the following `add-iam-policy-binding` command to grant a Dataproc Metastore predefined role to an IAM principal
(user account or service account).

<br />

```
  gcloud projects add-iam-policy-binding PROJECT_ID \
     --member=PRINCIPAL \
     --role=METASTORE_ROLE
```

<br />

Replace the following:

- `PROJECT_ID`: The ID of the project you want to enable Metastore access to.
- `PRINCIPAL`: The type and email ID (email address) of the principal.
  - For user accounts: user:<var translate="no">EMAIL_ID</var>
  - For service accounts: serviceAccount:<var translate="no">EMAIL_ID</var>
  - For Google Groups: group:<var translate="no">EMAIL_ID</var>
- `METASTORE_ROLE`: One of the following values, depending on the role you want to grant the principal: `roles/metastore.editor`, or `roles/metastore.admin`. For details about the permissions these roles grant, see [Dataproc Metastore IAM roles](https://docs.cloud.google.com/dataproc-metastore/docs/iam-roles).