Google 云函数部署 "allow unauthenticated invocations..."
Google Cloud Functions Deploy "allow unauthenticated invocations..."
每当我必须使用 gcloud
SDK 部署新的 python 函数时,我都会收到此消息
Allow unauthenticated invocations of new function [function-name]?
(y/N)?
WARNING: Function created with limited-access IAM policy. To enable unauthorized access consider
"gcloud alpha functions add-iam-policy-binding function-name --region=europe-west1 --member=allUsers --role=roles/cloudfunctions.invoker"
我可以在命令中添加任何标志以使其在部署时成为 NO
吗?
这是我用来部署一个函数的示例命令:
gcloud functions deploy function-name --region=europe-west1 --entry-point function-entry-point --trigger-resource "projects/my-project/databases/(default)/documents/user_ids/{user_id}" --trigger-event providers/cloud.firestore/eventTypes/document.create --runtime python37 --timeout 60 --project my-project
来自https://cloud.google.com/sdk/docs/scripting-gcloud#disabling_prompts:
You can disable prompts from gcloud CLI commands by setting the disable_prompts
property in your configuration to True
or by using the global --quiet
or -q
flag.
因此,对于您的示例,您可以 运行:
gcloud functions deploy function-name --quiet --region=europe-west1 --entry-point function-entry-point --trigger-resource "projects/my-project/databases/(default)/documents/user_ids/{user_id}" --trigger-event providers/cloud.firestore/eventTypes/document.create --runtime python37 --timeout 60 --project my-project
- Select 服务
- 单击“显示信息面板”以显示“权限”选项卡。
- 在添加成员字段中,allUsers
- Select 来自角色的 Cloud Functions Invoker
- 添加
或
gcloud functions add-iam-policy-binding FUNCTION \
--member='serviceAccount:FUNCTION_IDENTITY' \
--role='roles/cloudfunctions.invoker'
gcloud run services add-iam-policy-binding [SERVICE_NAME] \
--member="allUsers" \
--role="roles/cloudfunctions.invoker"
我也刚遇到这个问题,发现您可以提供 --no-allow-unauthenticated
到 pre-emptively 回答“否”这个问题。
gcloud functions deploy MyFunction \
--runtime=go116 --trigger-http --no-allow-unauthenticated
每当我必须使用 gcloud
SDK 部署新的 python 函数时,我都会收到此消息
Allow unauthenticated invocations of new function [function-name]?
(y/N)?
WARNING: Function created with limited-access IAM policy. To enable unauthorized access consider
"gcloud alpha functions add-iam-policy-binding function-name --region=europe-west1 --member=allUsers --role=roles/cloudfunctions.invoker"
我可以在命令中添加任何标志以使其在部署时成为 NO
吗?
这是我用来部署一个函数的示例命令:
gcloud functions deploy function-name --region=europe-west1 --entry-point function-entry-point --trigger-resource "projects/my-project/databases/(default)/documents/user_ids/{user_id}" --trigger-event providers/cloud.firestore/eventTypes/document.create --runtime python37 --timeout 60 --project my-project
来自https://cloud.google.com/sdk/docs/scripting-gcloud#disabling_prompts:
You can disable prompts from gcloud CLI commands by setting the
disable_prompts
property in your configuration toTrue
or by using the global--quiet
or-q
flag.
因此,对于您的示例,您可以 运行:
gcloud functions deploy function-name --quiet --region=europe-west1 --entry-point function-entry-point --trigger-resource "projects/my-project/databases/(default)/documents/user_ids/{user_id}" --trigger-event providers/cloud.firestore/eventTypes/document.create --runtime python37 --timeout 60 --project my-project
- Select 服务
- 单击“显示信息面板”以显示“权限”选项卡。
- 在添加成员字段中,allUsers
- Select 来自角色的 Cloud Functions Invoker
- 添加
或
gcloud functions add-iam-policy-binding FUNCTION \
--member='serviceAccount:FUNCTION_IDENTITY' \
--role='roles/cloudfunctions.invoker'
gcloud run services add-iam-policy-binding [SERVICE_NAME] \
--member="allUsers" \
--role="roles/cloudfunctions.invoker"
我也刚遇到这个问题,发现您可以提供 --no-allow-unauthenticated
到 pre-emptively 回答“否”这个问题。
gcloud functions deploy MyFunction \
--runtime=go116 --trigger-http --no-allow-unauthenticated