Google Cloud Storage - Set Acl for Google Compute Engine



嗨,我想更改我的 ACL 文件以允许 Google 计算引擎在我的存储桶上写入

这是我的 ACL 的样子:

<?xml version="1.0" ?>
<AccessControlList>
    <Owner>
        <ID>XX</ID>
    </Owner>
    <Entries>
        <Entry>
            <Scope type="GroupById">
                <ID>XX</ID>
            </Scope>
            <Permission>FULL_CONTROL</Permission>
        </Entry>
        <Entry>
            <Scope type="AllUsers"/>
            <Permission>READ</Permission>
        </Entry>
        <Entry>
            <Scope type="UserByEmail">
                <EmailAddress>XX@appspot.gserviceaccount.com</EmailAddress>
            </Scope>
            <Permission>WRITE</Permission>
        </Entry>
    </Entries>
</AccessControlList>

或者我不知道有没有其他方法可以做到这一点?

计算引擎服务帐户是访问同一项目中的云存储桶的一种非常干净的方式。无需在每个存储桶或对象上设置 ACL。

总之:

host$ gcutil addinstance reader --service_account_scopes=storage-rw
<output elided...>
host$ gcutil ssh reader
<output elided...>
reader$ gsutil ls gs://YOUR_BUCKET
<outputs the list of objects in your bucket>

。其中YOUR_BUCKET是与计算引擎位于同一项目中的云存储桶。Cloud Storage 的范围别名为:storage-r、storage-w、storage-rw 和 storage-full。

如果您想启用跨项目的访问权限,可以通过将 GCE 项目的服务帐号的电子邮件地址添加到其他项目中的 Google 存储空间资源(存储桶/对象)来实现此目的。查找服务帐号电子邮件地址的最简单方法是在上述启动的 GCE 实例中执行以下命令:

reader$ curl -s http://metadata/0.1/meta-data/service-accounts/default | python -mjson.tool
{
    "scopes": [
        "https://www.googleapis.com/auth/devstorage.read_only"
    ], 
    "serviceAccount": "abc123.default@developer.gserviceaccount.com"
}

详情请见此处:https://developers.google.com/compute/docs/authentication

我在列表中添加了服务帐户,实际上它的工作非常简单

最新更新