[英]Google Cloud Function Not able to delete Bigquery Dataset
I have created a cloud function which will list down all Bigquery datasets which are falling under certain criteria, and then delete all such Bigquery datasets.我创建了一个云 function,它将列出所有符合特定条件的 Bigquery 数据集,然后删除所有此类 Bigquery 数据集。 I am using following Delete API request:-
我正在使用以下删除 API 请求:-
bigquery_client.delete_dataset(
dataset['schema_name'], delete_contents=True, not_found_ok=True
) # Make an API request.
its giving following error:-它给出以下错误: -
fn_clean_bq_datasetrrhier7sk4oz Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/__init__.py", line 99, in view_func return function(request._get_current_object()) File "/workspace/main.py", line 76, in clean_bq_dataset bigquery_client.delete_dataset(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/bigquery/client.py", line 1571, in delete_dataset self._call_api( File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/bigquery/client.py", line 759, in _call_api return call()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/api_core/retry.py", line 283, in retry_wrapped_func return retry_target( File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/api_core/retry.py", line 190, in retry_target return target()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/_http/__init__.py", line 494, in api_request raise exceptions.from_http_response(response) google.api_core.exceptions.
Forbidden: 403 DELETE https://bigquery.googleapis.com/bigquery/v2/projects/xxxxxxxx/datasets/dataset_v05c248634?deleteContents=true&prettyPrint=false: Access Denied: Dataset xxxxxxxxx:dataset_v05c248634: Permission bigquery.datasets.delete denied on dataset xxxxxxxxxxx:dataset_v05c248634 (or it may not exist).
Please suggest what permissions are missing here on Google cloud function.请建议在谷歌云 function 上缺少哪些权限。
To delete a dataset, you need the following IAM permissions:要删除数据集,您需要以下 IAM 权限:
bigquery.datasets.delete (lets you delete a dataset)
bigquery.tables.delete (lets you delete tables and views)
Each of the following predefined IAM roles includes the permissions that you need in order to delete a dataset:以下每个预定义 IAM 角色都包含您删除数据集所需的权限:
roles/bigquery.dataOwner
roles/bigquery.admin
Additionally, if you have the bigquery.datasets.create permission, you can delete the datasets and tables that you create.此外,如果您拥有 bigquery.datasets.create 权限,则可以删除您创建的数据集和表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.