GCE 实例忽略服务帐户角色
GCE instance ignoring service account roles
我目前正在尝试提供一个 GCE 实例,它将执行一个 Docker 容器,以便从 Web 检索一些信息并将它们推送到 BigQuery。
现在,新创建的服务帐户(下面的屏幕截图)不会影响 api 范围。这显然会使容器在向 BQ 进行身份验证时失败。有趣的是,当我从 GUI 手动使用 GCE 默认服务帐户和 select 身份验证范围时,一切都很顺利。
我无法理解为什么以下服务帐户不向计算机打开 api 身份验证范围。我可能忽略了一些非常简单的东西。
上下文
创建虚拟机并运行使用以下gcloud
命令:
#!/bin/sh
gcloud compute instances create-with-container gcp-scrape \
--machine-type="e2-micro" \
--boot-disk-size=10 \
--container-image="gcr.io/my_project/gcp_scrape:latest" \
--container-restart-policy="on-failure" \
--zone="us-west1-a" \
--service-account gcp-scrape@my_project.iam.gserviceaccount.com \
--preemptible
这是使用我的自定义服务帐户时 bigquery 出错的原因:
Access Denied: BigQuery BigQuery: Missing required OAuth scope. Need BigQuery or Cloud Platform read scope.
您没有指定 --scopes
标志,因此该实例使用 default scope 不包括 BigQuery。
To let the instance access all services that the service account can access,将 --scopes https://www.googleapis.com/auth/cloud-platform
添加到您的命令行。
我目前正在尝试提供一个 GCE 实例,它将执行一个 Docker 容器,以便从 Web 检索一些信息并将它们推送到 BigQuery。
现在,新创建的服务帐户(下面的屏幕截图)不会影响 api 范围。这显然会使容器在向 BQ 进行身份验证时失败。有趣的是,当我从 GUI 手动使用 GCE 默认服务帐户和 select 身份验证范围时,一切都很顺利。
我无法理解为什么以下服务帐户不向计算机打开 api 身份验证范围。我可能忽略了一些非常简单的东西。
上下文
创建虚拟机并运行使用以下gcloud
命令:
#!/bin/sh
gcloud compute instances create-with-container gcp-scrape \
--machine-type="e2-micro" \
--boot-disk-size=10 \
--container-image="gcr.io/my_project/gcp_scrape:latest" \
--container-restart-policy="on-failure" \
--zone="us-west1-a" \
--service-account gcp-scrape@my_project.iam.gserviceaccount.com \
--preemptible
这是使用我的自定义服务帐户时 bigquery 出错的原因:
Access Denied: BigQuery BigQuery: Missing required OAuth scope. Need BigQuery or Cloud Platform read scope.
您没有指定 --scopes
标志,因此该实例使用 default scope 不包括 BigQuery。
To let the instance access all services that the service account can access,将 --scopes https://www.googleapis.com/auth/cloud-platform
添加到您的命令行。