当尝试创建“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
日志将有详细信息错误.详细信息[x].违规[x].类型。日志条目指出了违反的限制。
以下日志条目显示位置违规:
"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."
}
]
}
]
}