无法通过gsutil将cp文件传输到Google Object Storage

时间:2019-03-13 21:36:21

标签: google-cloud-platform google-cloud-storage

我确定我已授予我可以授予的所有权限:

louchenyao@dev ~> gcloud auth list
                  Credentialed Accounts
ACTIVE  ACCOUNT
*       290002171211-compute@developer.gserviceaccount.com
        louchenyao@gmail.com

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

louchenyao@dev ~> curl -H 'Metadata-Flavor: Google' "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/scopes"
https://www.googleapis.com/auth/devstorage.read_write
https://www.googleapis.com/auth/logging.write
https://www.googleapis.com/auth/monitoring.write
https://www.googleapis.com/auth/service.management.readonly
https://www.googleapis.com/auth/servicecontrol
https://www.googleapis.com/auth/trace.append
louchenyao@dev ~> gsutil cp pgrc.sh gs://hidden-buckets-name
Copying file://pgrc.sh [Content-Type=text/x-sh]...
AccessDeniedException: 403 Insufficient Permission

并且我已将Storage Admin授予云计算默认帐户。

如果我切换到个人帐户,则可以使用。所以我想知道我是否错过了一些重要的权限。

1 个答案:

答案 0 :(得分:0)

使用默认服务帐户授予访问权以从VM实例写入存储桶: change API access scopes for the VM instance,请按照以下步骤操作:

  • Stop实例
  • 输入VM instance details> Edit
  • 更改Cloud API access scopes> Storage: Full
  • Save进行更改并启动实例

还可以在控制台的Identity and API access部分中设置access scopes创建VM实例

如果您不想使用默认服务帐户create new service account for your VM Instance,并使用它来访问存储桶。