授权 GCE 访问 GCS
Authorizing GCE to Access GCS
我的 Google 计算引擎中有一个 django 应用程序 运行,它需要将视频文件上传到我在 Google 云存储中的存储桶。在搜索身份验证方法时,我发现 this doc。在 Setting the scope of service account access for instances 部分,它说我需要在创建 VM 时在设置中启用 Cloud Platform 访问权限。我想知道这是否是必须的,是否有任何其他方式可以让我从计算引擎中的应用程序访问我的云存储桶。因为创建一个新的 VM 和设置环境是非常耗时的。任何投入将不胜感激。提前致谢。
如 the page you linked to 中所述,要从 Google Compute Engine 到 Google Cloud Storage 进行身份验证,您有多种选择:
使用 VM 作用域:这必须在创建 VM 之前设置,因为一旦创建 VM,作用域就不可变了。如果您想要只读访问权限,则需要添加范围 devstorage.read_only
(缩写形式)或 https://www.googleapis.com/auth/devstorage.read_only
(完整路径)。如果您想要读写访问权限,则应使用范围 devstorage.read_write
(缩写形式)或 https://www.googleapis.com/auth/devstorage.read_write
(完整路径)。
Note: there's also a feature gcloud beta compute instances set-scopes
to update GCE VM scopes at runtime.
使用范围的替代方法是使用 JSON 身份验证令牌,例如通过 Service accounts which can be used by Google API client libraries 连接到 Google 云存储。
我的 Google 计算引擎中有一个 django 应用程序 运行,它需要将视频文件上传到我在 Google 云存储中的存储桶。在搜索身份验证方法时,我发现 this doc。在 Setting the scope of service account access for instances 部分,它说我需要在创建 VM 时在设置中启用 Cloud Platform 访问权限。我想知道这是否是必须的,是否有任何其他方式可以让我从计算引擎中的应用程序访问我的云存储桶。因为创建一个新的 VM 和设置环境是非常耗时的。任何投入将不胜感激。提前致谢。
如 the page you linked to 中所述,要从 Google Compute Engine 到 Google Cloud Storage 进行身份验证,您有多种选择:
使用 VM 作用域:这必须在创建 VM 之前设置,因为一旦创建 VM,作用域就不可变了。如果您想要只读访问权限,则需要添加范围
devstorage.read_only
(缩写形式)或https://www.googleapis.com/auth/devstorage.read_only
(完整路径)。如果您想要读写访问权限,则应使用范围devstorage.read_write
(缩写形式)或https://www.googleapis.com/auth/devstorage.read_write
(完整路径)。Note: there's also a feature
gcloud beta compute instances set-scopes
to update GCE VM scopes at runtime.使用范围的替代方法是使用 JSON 身份验证令牌,例如通过 Service accounts which can be used by Google API client libraries 连接到 Google 云存储。