gsutil 指令所需的 IAM 權限

下表列出在指定資源上執行每個 Cloud Storage gsutil 指令所需的 Identity and Access Management (IAM) 權限。IAM 權限會組合為角色。您可以將角色授予使用者和群組

這個頁面也會提供下列資訊:

指令 子指令 必要 IAM 權限
autoclass get storage.buckets.get
autoclass set storage.buckets.update
cat storage.objects.get
compose storage.objects.get
storage.objects.create
storage.objects.delete1
config
cors get storage.buckets.get
cors set storage.buckets.update
cp storage.objects.list2 (用於目的地值區)
storage.objects.get (用於來源物件)
storage.objects.create (用於目的地值區)
storage.objects.delete3 (用於目的地值區)
defstorageclass get storage.buckets.get
defstorageclass set storage.buckets.update
du storage.objects.get
hash storage.objects.get
help
hmacKeys create storage.hmacKeys.create
hmacKeys delete storage.hmacKeys.delete
hmacKeys get storage.hmacKeys.get
hmacKeys list storage.hmacKeys.list
hmacKeys update storage.hmacKeys.update
iam get storage.buckets.get
storage.buckets.getIamPolicy
iam setch storage.buckets.get
storage.buckets.getIamPolicy
storage.buckets.setIamPolicy
storage.buckets.update
kms authorize resourceManager.projects.get
iam.serviceAccounts.create4
cloudkms.cryptoKeys.setIamPolicy (用於已授權 Cloud KMS 金鑰)
kms encryption storage.buckets.get
kms encryption -d storage.buckets.get
storage.buckets.update
kms encryption -k storage.buckets.get
storage.buckets.update
resourceManager.projects.get5
cloudkms.cryptoKeys.setIamPolicy5
kms serviceaccount resourceManager.projects.get
label get storage.buckets.get
label set/ch storage.buckets.update
lifecycle get storage.buckets.get
lifecycle set/ch storage.buckets.update
logging get storage.buckets.get
logging set storage.buckets.update
ls (列出 bucket) storage.buckets.list
storage.buckets.getIamPolicy6
ls (商家資訊物件) storage.objects.list
storage.objects.getIamPolicy7
ls -b storage.buckets.get
storage.buckets.getIamPolicy6
mb storage.buckets.create
mv storage.objects.list2 (用於目的地值區)
storage.objects.get (用於來源物件)
storage.objects.create (用於目的地值區)
storage.objects.delete (用於來源值區)
storage.objects.delete3 (用於目的地值區)
notification create storage.buckets.update
pubsub.topics.get (用於包含 Pub/Sub 主題的專案)
pubsub.topics.create8 (用於包含 Pub/Sub 主題的專案)
pubsub.topics.getIamPolicy (用於接收通知之用的 Pub/Sub 主題)
pubsub.topics.setIamPolicy8 (用於接收通知之用的 Pub/Sub 主題)
notification create -s storage.buckets.update
notification delete storage.buckets.get
storage.buckets.update
notification list storage.buckets.get
notification watchbucket storage.buckets.update
notification stopchannel storage.buckets.update
pap get storage.buckets.get
pap set storage.buckets.get
storage.buckets.update
storage.buckets.setIamPolicy10
perfdiag storage.buckets.get
storage.objects.create
storage.objects.delete
storage.objects.list
storage.objects.get
rb storage.buckets.delete
requesterpays get storage.buckets.get
requesterpays set on storage.buckets.update
requesterpays set off storage.buckets.update
resourcemanager.projects.createBillingAssignment9
retention clearevent-defaultlockset storage.buckets.update
retention eventtemp storage.objects.get
storage.objects.list
storage.objects.update
retention get storage.buckets.get
rewrite -k storage.objects.list
storage.objects.get
storage.objects.create
storage.objects.delete
rewrite -s storage.objects.list
storage.objects.get
storage.objects.create
storage.objects.delete
storage.objects.update
rm storage.objects.delete
rm -a storage.objects.delete
storage.objects.list
rm -r (刪除值區) storage.buckets.delete
storage.objects.delete
storage.objects.list
rpo get storage.buckets.get
rpo set storage.buckets.get
storage.buckets.update
rsync storage.objects.get (針對來源物件和目標值區)
storage.objects.create (針對目標值區)
storage.objects.delete11 (針對目標值區)
storage.objects.list (針對來源和目標值區)
rsync -n storage.objects.list (用於來源和目的地值區)
setmeta storage.objects.get
storage.objects.list
storage.objects.update
signurl 無;不過,在指令中使用金鑰的服務帳戶必須有權執行要求,並將要求編碼至已簽署的網址。
stat storage.objects.get
test
ubla set storage.buckets.get
storage.buckets.update
ubla get storage.buckets.get
update
version
versioning get storage.buckets.get
versioning set storage.buckets.update
web get storage.buckets.get
web set storage.buckets.update

1只有在組合物件名稱與值區中現有物件名稱相同時,才需要這項權限。

2只有在指令中的目標位置包含物件路徑時,才需要這項權限。

3只有在使用平行複合上傳時,或未採用 -n 旗標,但插入的物件與值區中現有物件名稱相同時,才需要這項權限。

4只有在您目前沒有與專案有關的 Cloud Storage 服務帳戶時,才需要這項權限。

5如果您使用 gsutil kms encryption -k,且專案的服務帳戶沒有存取所要求 Cloud KMS 金鑰的權限,gsutil 會執行 gsutil kms authorize 以授予服務帳戶必要權限。

6只有在您要將 IAM 政策列入詳細資料中時,才需要這項權限。

7只有在您要將 IAM 政策列入詳細資料中時,才需要這項權限,且不適用於已啟用統一值區層級存取權的值區。

8如果主題已存在且相關服務帳戶可存取該主題,則不需要這些權限。

9只有在您的要求中未包含計費專案時,才需要這項權限。詳情請參閱要求者付費的使用及存取需求一節。

10如果指令不會變更值區設定,則不需要這項權限。

11只有在使用 -d 旗標,或插入的物件名稱與值區中現有物件名稱相同,但資料不同時,才需要這項權限。

與 ACL 相關的方法

下表列出執行 gsutil 指令時所需的 IAM 權限,這些指令專門用於管理 ACL。這些指令僅適用於已停用統一值區層級存取權的值區。

指令 子指令 動作所需資源 必要 IAM 權限
acl get 值區 storage.buckets.get
storage.buckets.getIamPolicy
acl setch 值區 storage.buckets.get
storage.buckets.getIamPolicy
storage.buckets.setIamPolicy
storage.buckets.update
acl get 物件 storage.objects.get
storage.objects.getIamPolicy
acl setch 物件 storage.objects.get
storage.objects.getIamPolicy
storage.objects.setIamPolicy
storage.objects.update
cp -acp -p 物件 storage.objects.lista (針對目標值區)
storage.objects.get (針對來源物件)
storage.objects.create (針對目標值區)
storage.objects.deleteb (針對目標值區)
storage.objects.getIamPolicy (針對來源物件)
storage.objects.setIamPolicy (針對目標值區)
defacl get 值區 storage.buckets.get
storage.buckets.getIamPolicy
defacl setch 值區 storage.buckets.get
storage.buckets.getIamPolicy
storage.buckets.setIamPolicy
storage.buckets.update
iam get 物件 storage.objects.get
storage.objects.getIamPolicy
iam setch 物件 storage.objects.get
storage.objects.getIamPolicy
storage.objects.setIamPolicy
storage.objects.update
mv -amv -p 物件 storage.objects.lista (針對目標值區)
storage.objects.get (針對來源物件)
storage.objects.create (針對目標值區)
storage.objects.delete (針對來源值區)
storage.objects.deleteb (針對目標值區)
storage.objects.getIamPolicy (針對來源物件)
storage.objects.setIamPolicy (針對目標值區)
rsync -arsync -p 物件 storage.objects.get (用於來源物件和目標值區)
storage.objects.create (用於目標值區)
storage.objects.deletec (用於目標值區)
storage.objects.list (用於來源和目標值區)
storage.objects.getIamPolicy (用於來源物件)
storage.objects.setIamPolicy (用於目標值區)

a 只有在指令中的目標位置包含物件路徑時,才需要這項權限。

b只有在使用平行複合上傳時,或未採用 -n 旗標,但插入的物件與值區中現有物件名稱相同時,才需要這項權限。

c只有在使用 -d 旗標時,或插入的物件與值區中現有物件名稱相同,但資料不同時,才需要這項權限。

-u 頂層旗標

如果您使用 -u 全域旗標指定需支付您要求費用的專案,就必須擁有所指定專案的 serviceusage.services.use 權限。舉例來說,存取已啟用要求者付費功能的值區時,就會使用 -u 旗標。

萬用字元與遞迴標記

如果您使用 URI 萬用字元在指令中選取多個物件,就必須擁有物件所在值區的 storage.objects.list 權限。同樣地,如果您使用 URI 萬用字元在指令中選取多個值區,就必須擁有值區所在專案的 storage.buckets.list 權限。

如果您使用遞迴旗標 (-r-R),就必須具備相關值區的 storage.objects.list 權限,以及您使用的特定指令所需的權限。

-m 頂層旗標

通常,如果使用 gsutil 指令在多個物件或值區上執行動作時,指令會因第一個錯誤而失敗。但是,使用 -m 全域標記時,gsutil 會記錄指令發生的任何錯誤並繼續作業。

舉例來說,假設您嘗試在一系列的物件上執行 acl set 指令,但您卻只擁有在其中部分物件上執行這項指令的權限。如果您不使用旗標 -m,gsutil 會成功套用 ACL,直到所執行的物件不具備套用 ACL 的權限為止,這時 gsutil 就會失敗。如果您使用的是標記 -m,gsutil 會在嘗試將 ACL 套用至您不具備權限的物件時,記錄所發生的錯誤,但同時又會繼續作業。

後續步驟