简体   繁体   English

从云存储导入CSV到云SQL时拒绝服务帐户访问(权限问题?)

[英]Access denied for service account (permission issue?) when importing a csv from cloud storage to cloud sql

I'm trying to populate a mysql db with a csv that i have in cloud storage 我正在尝试使用云存储中的csv填充mysql db

I'm using the API Explorer to execute the request with the following request body: 我正在使用API资源管理器通过以下请求正文执行请求:

{
  "importContext": {
    "csvImportOptions": {
      "columns": [
        "col1",
        "col2",
        "col3"
      ],
      "table": "table_name"
    },
    "database": "db_name",
    "fileType": "CSV",
    "kind": "sql#importContext",
    "uri": "gs://some_bucket/somecsv.csv"
  }
}

When i hit the execute button i receive a 200 response with the following body 当我按下执行按钮时,我收到以下正文的200响应

{
 "kind": "sql#operation",
 "selfLink": "https://www.googleapis.com/sql/v1beta4/projects/somelink",
 "targetProject": "some-project",
 "targetId": "some-tarjet",
 "targetLink": "https://www.googleapis.com/sql/v1beta4/projects/somelink",
 "name": "some-name",
 "operationType": "IMPORT",
 "status": "PENDING",
 "user": "myuser@mydomain.com",
 "insertTime": "somedate",
 "importContext": {
  ...
 }
}

But if i go to the detail instance page in the google console i see this message: 但是,如果我转到Google控制台中的详细实例页面,则会看到以下消息:

gs://link-to-csv: Access denied for account oosyrcl32gnzypxg4uhqw54uab@somename.iam.gserviceaccount.com (permission issue?) gs:// link-to-csv:拒绝访问帐户oosyrcl32gnzypxg4uhqw54uab@somename.iam.gserviceaccount.com(权限问题?)

I'm authenticated with the same account that created the bucket in cloud storage where the csv is and this also happens using the python sdk. 我使用在csv所在的云存储中创建存储桶的同一帐户进行了身份验证,这也使用python sdk进行了验证。

You are trying to do an import from your bucket to your Cloud SQL instance, but, said import is going to be made by a service account, one in particular, which can be seen in the “Service account” section while seeing the details of your Cloud SQL instance. 您正在尝试从存储桶中导入Cloud SQL实例,但是,该导入将由一个服务帐户进行,尤其是一个服务帐户,可以在“服务帐户”部分中看到该帐户的详细信息,您的Cloud SQL实例。

It might be that the CloudSQL service account does not have appropriate permissions to access the Cloud Storage bucket with the data to import. CloudSQL服务帐户可能没有适当的权限来访问带有要导入的数据的Cloud Storage存储桶。

In order to create a successful import between SQL instance and Storage buckets, proper permissions should be set first. 为了在SQL实例和存储桶之间创建成功的导入,应首先设置适当的权限。 You should give to the service account "oosyrcl32gnzypxg4uhqw54uab@speckle-umbrella-27.iam.gserviceaccount.com" the Storage Object Viewer role . 您应该为服务帐户“ oosyrcl32gnzypxg4uhqw54uab@speckle-umbrella-27.iam.gserviceaccount.com”赋予“ 存储对象查看器”角色

  1. Go to: https://console.cloud.google.com/iam-admin/iam 前往: https//console.cloud.google.com/iam-admin/iam
  2. Click Add, to add a new member. 单击添加,添加新成员。
  3. Paste the gserviceaccount.com email address that was presented in the error message into the New Members field. 将错误消息中显示的gserviceaccount.com电子邮件地址粘贴到“新成员”字段中。
  4. Add 2 roles: 添加2个角色:
    1. Cloud SQL Viewer Cloud SQL查看器
    2. Storage Object Admin 存储对象管理
  5. Click Save. 单击保存。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用云存储时对 Cloud KMS 密钥的权限被拒绝 - Permission denied on Cloud KMS key when using cloud storage 无法访问 Cloud 中的 Google Cloud Storage 服务帐户密钥文件 - Unable to access Google Cloud Storage service account key file in Cloud Google Cloud Storage Transfer Service 失败并出现 PERMISSION_DENIED 错误 - Google Cloud Storage Transfer Service fails with PERMISSION_DENIED error 在云运行上部署时,服务帐户的权限“iam.serviceaccounts.actAs”被拒绝 - Permission 'iam.serviceaccounts.actAs' denied on service account when deploying on cloud run 通过Python中的服务帐户访问Google Cloud Storage的权限 - Permission to Google Cloud Storage via service account in Python 使用 Cloud Shell 从 Cloud Storage CSV 导入到 Cloud SQL - CSV import to Cloud SQL from Cloud Storage using Cloud Shell 部署云时服务帐户权限问题 function - service account permission issue while deploying cloud function 如何在不使用本地服务帐户密钥文件的情况下从 Cloud Run 服务访问 Google Cloud Storage 存储桶? - How to access to a Google Cloud Storage bucket from a Cloud Run service without using a local Service Account key file? 使用服务帐户从Google Cloud功能访问Google Cloud SQL实例 - Access Google cloud SQL instance from Google cloud function using a service account 授予服务帐户访问谷歌云存储中的一个存储桶的权限 - Give service account access to one bucket in google cloud storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM