本文說明如果沒有資源的必要存取權限,可能會遇到的錯誤訊息。
導致權限錯誤訊息的問題
如果您嘗試存取沒有權限的資源, Cloud de Confiance 控制台、Google Cloud CLI 和 REST API 都會顯示錯誤訊息。
這些錯誤訊息可能是由下列原因所造成:
- 您沒有必要權限。您必須具有允許政策角色繫結和必要權限。如果您沒有必要權限, Cloud de Confiance 會顯示錯誤訊息。
- 有拒絕政策會封鎖存取權。如果拒絕政策禁止您使用任何必要權限, Cloud de Confiance 就會顯示錯誤訊息。
- 資源不存在。如果資源不存在,Cloud de Confiance 會顯示錯誤訊息。
以下各節將說明Cloud de Confiance 控制台、gcloud CLI 和 REST API 的錯誤訊息。
Cloud de Confiance 控制台錯誤訊息
在 Cloud de Confiance 控制台中,錯誤訊息看起來類似以下內容:
這些錯誤訊息包含下列資訊:
- 您嘗試存取的資源:錯誤頁面的標題會顯示資源名稱,指出您遇到權限錯誤時嘗試存取的資源。
- 缺少必要權限:存取資源所需的權限清單。
包含必要權限的 IAM 角色清單: 這份清單僅選列部分項目,並非完整內容。清單中列出建議用來解決存取問題的角色。Cloud de Confiance 排序依據為角色允許的動作類型、服務關聯性和權限數量。
如果您具備授予角色所需的權限,這個部分會顯示「選取要授予的角色」。如果您沒有必要權限,這個部分會顯示「要求特定角色」。
您可以點選角色,進一步瞭解該角色,並要求授予您該角色。如果您具備授予角色的必要權限,可以自行授予角色,不必提出要求。
政策疑難排解工具網址:您可以透過這個連結前往政策疑難排解工具摘要,查看這項存取要求的相關資訊。
Google Cloud CLI 和 REST API 錯誤訊息
錯誤訊息的確切措辭取決於您執行的指令,但通常包含下列資訊:
- 必要權限
- 您嘗試對其執行動作的資源
- 驗證帳戶
- 錯誤的專屬 ID
- 這個錯誤的政策疑難排解工具摘要連結
舉例來說,如果您沒有權限列出專案中的值區,系統會顯示類似下列內容的錯誤訊息:
gcloud
ERROR: (gcloud.storage.buckets.list) PERMISSION_DENIED:
EMAIL_ADDRESS does not have
storage.buckets.list access to the Google Cloud project. Permission
'storage.buckets.list' denied on resource (or it may not exist). This command
is authenticated as EMAIL_ADDRESS which
is the active account specified by the [core/account] property.
- '@type': type.googleapis.com/google.rpc.ErrorInfo
domain: storage.googleapis.com
metadata:
permission: storage.buckets.list
error_info_id: ERROR_ID
reason: IAM_PERMISSION_DENIED
REST
{
"error": {
"code": 403,
"message": "Permission 'storage.buckets.list' denied on resource (or it may not exist). Remediate access with this Troubleshooter URL or share it with your administrator - https://console.cloud.s3nscloud.fr/iam-admin/troubleshooter;errorId=ERROR_ID .",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "forbidden",
"domain": "global",
"metadata": {
"error_info_id": "ERROR_ID",
"permission": "storage.buckets.list"
}
}
]
}
}