This page explains how to view, understand, and apply IAM role recommendations for BigQuery datasets. Role recommendations help you enforce the principle of least privilege by ensuring that principals have only the permissions that they actually need.
Before you begin
Enable the IAM and Recommender APIs.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.Ensure that you have an organization-level or project-level activation of the Premium or Enterprise tier of Security Command Center. For more information, see Billing questions.
Understand role recommendations.
Set up authentication.
Select the tab for how you plan to use the samples on this page:
gcloud
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
Required IAM roles
To get the permissions that you need to manage dataset-level role recommendations, ask your administrator to grant you the following IAM roles:
- Role Viewer (
roles/iam.roleViewer) on your project - IAM Recommender Admin (
roles/recommender.iamAdmin) on your project - BigQuery Data Owner (
roles/bigquery.dataOwner) on your dataset
For more information about granting roles, see Manage access to projects, folders, and organizations.
These predefined roles contain the permissions required to manage dataset-level role recommendations. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to manage dataset-level role recommendations:
-
To view recommendations:
-
iam.roles.geton your project -
iam.roles.liston your project -
recommender.iamPolicyRecommendations.geton your project -
recommender.iamPolicyRecommendations.liston your project -
recommender.iamPolicyInsights.geton your project -
recommender.iamPolicyInsights.liston your project -
bigquery.datasets.getIamPolicyon your dataset
-
-
To apply and dismiss recommendations:
-
recommender.iamPolicyRecommendations.updateon your project -
bigquery.datasets.setIamPolicyon your dataset
-
You might also be able to get these permissions with custom roles or other predefined roles.
Review and apply recommendations
You can review and apply dataset-level role recommendations with the Google Cloud CLI and the Recommender API.
gcloud
Review your recommendations:
To list your dataset-level recommendations, run the
gcloud recommender recommendations list
command, filtering for only BigQuery dataset recommendations:
gcloud recommender recommendations list \
--location=LOCATION \
--recommender=google.iam.policy.Recommender \
--project=PROJECT_ID \
--format=json \
--filter="recommenderSubtype:REMOVE_ROLE_BIGQUERY_DATASET OR recommenderSubtype:REPLACE_ROLE_BIGQUERY_DATASET"
Replace the following values:
LOCATION: The region where your Cloud Storage datasets are located—for example,usorus-central1.PROJECT_ID: The ID of the Google Cloud project that contains your BigQuery datasets. Project IDs are alphanumeric strings, likemy-project.
The response is similar to the following example. In this example, all users
with the Editor role on the project my-project
(projectEditor:my-project) have the BigQuery Data Editor role
(roles/bigquery.dataEditor) on the dataset dataset-1.
However, this role hasn't been used in the past
90 days. As a result, the role recommendation suggests that
you revoke the role:
[ { "associatedInsights": [ { "insight": "projects/1069248613794/locations/us/insightTypes/google.iam.policy.Insight/insights/984eccca-0241-472f-baab-2557dd0d7282" } ], "content": { "operationGroups": [ { "operations": [ { "action": "remove", "path": "/iamPolicy/bindings/*/members/*", "pathFilters": { "/iamPolicy/bindings/*/condition/expression": "", "/iamPolicy/bindings/*/members/*": "projectEditor:my-project", "/iamPolicy/bindings/*/role": "roles/bigquery.dataEditor" }, "resource": "//bigquery.googleapis.com/projects/my-project/datasets/dataset-1", "resourceType": "bigquery.googleapis.com/Dataset" } ] } ], "overview": { "addedRoles": [], "member": "projectEditor:my-project", "minimumObservationPeriodInDays": "0", "removedRole": "roles/bigquery.dataEditor", "resource": "//bigquery.googleapis.com/projects/my-project/datasets/dataset-1" } }, "description": "This role has not been used during the observation window.", "etag": "\"3b123bc08d028128\"", "lastRefreshTime": "2024-02-04T08:00:00Z", "name": "projects/1069248613794/locations/us/recommenders/google.iam.policy.Recommender/recommendations/0e9831fe-6810-476b-b14d-2b64bda17288", "primaryImpact": { "category": "SECURITY", "securityProjection": { "details": { "revokedIamPermissionsCount": 37 } } }, "priority": "P4", "recommenderSubtype": "REMOVE_ROLE_BIGQUERY_DATASET", "stateInfo": { "state": "ACTIVE" }, "targetResources": [ "//bigquery.googleapis.com/projects/my-project/datasets/dataset-1" ] }, { "associatedInsights": [ { "insight": "projects/1069248613794/locations/us/insightTypes/google.iam.policy.Insight/insights/9d11057e-9c71-410f-ad55-fc82d87761d0" } ], "content": { "operationGroups": [ { "operations": [ { "action": "remove", "path": "/iamPolicy/bindings/*/members/*", "pathFilters": { "/iamPolicy/bindings/*/condition/expression": "", "/iamPolicy/bindings/*/members/*": "user:alicexz@google.com", "/iamPolicy/bindings/*/role": "roles/bigquery.dataOwner" }, "resource": "//bigquery.googleapis.com/projects/my-project/datasets/dataset-1", "resourceType": "bigquery.googleapis.com/Dataset" } ] } ], "overview": { "addedRoles": [], "member": "user:alicexz@google.com", "minimumObservationPeriodInDays": "0", "removedRole": "roles/bigquery.dataOwner", "resource": "//bigquery.googleapis.com/projects/my-project/datasets/dataset-1" } }, "description": "This role has not been used during the observation window.", "etag": "\"1da285f7aa6438f1\"", "lastRefreshTime": "2024-02-04T08:00:00Z", "name": "projects/1069248613794/locations/us/recommenders/google.iam.policy.Recommender/recommendations/56013294-cf81-402a-8cde-25489545777c", "primaryImpact": { "category": "SECURITY", "securityProjection": { "details": { "revokedIamPermissionsCount": 64 }