
當嘗試建立“hello world”雲端函數時,我收到錯誤訊息:
“該請求違反了一項或多項組織政策。請參閱相應的違規行為以獲取更多信息。”
現在,違反了哪些組織政策?在日誌資源管理器中,我發現如下錯誤訊息:
{
insertId: "XXX"
logName: "projects/XXX/logs/cloudaudit.googleapis.com%2Factivity"
protoPayload: {10}
receiveTimestamp: "2021-11-26T11:42:16.735011108Z"
resource: {2}
severity: "ERROR"
timestamp: "2021-11-26T11:42:16.490247Z"
}
答案1
我找到了自己問題的解決方案:點擊“建立函數”後,我必須選擇“運行時、建置、連接和安全設定”->“連接”並選擇選項。
那裡沒有選擇任何選項,我想這是由於我的項目的網路設定所致。
現在我可以部署了:)
答案2
日誌記錄會有詳細信息error.details[x].violations[x].type。日誌條目指出了違反的約束。
以下日誌條目顯示位置違規:
"type": "constraints/gcp.resourceLocations"
日誌條目範例:
"error": {
"code": 400,
"message": "The request has violated one or more Org Policies. Please refer to the respective violations for more information."
"status": "FAILED_PRECONDITION"
"details\": [
{
"@type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "constraints/gcp.resourceLocations",
"subject": "orgpolicy:projects/<project>",
"description": "Constraint constraints/gcp.resourceLocations violated for projects/<project> attempting GenerateUploadUrlActionV1 with location set to us-central1. See https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints for more information."
}
]
}
]
}