Google 云没有足够的授权范围来调用云功能
Google Cloud insufficient auth scope to call cloud function
我正在尝试调用一个关闭 VM 实例的云函数:
gcloud functions call stopInstancePubSub --data '{"data":"<instance data in base64>"}'
当我从我的本地计算机或 gcloud 控制台 运行 它时,它工作得很好。但是我需要能够从实例本身内部 运行 它,当我尝试这样做时,这是抛出的错误:
ERROR: (gcloud.functions.call) ResponseError: status=[403], code=[Forbidden], message=[Request had insufficient authentication scopes.]
基本上,我希望能够将脚本安排到每天 运行(它会 运行 大约 2-3 小时)。因此,我使用云调度程序调用云函数,该函数每天凌晨 12 点启动脚本,并且可以正常工作,但我需要能够在脚本完成后关闭实例(以避免添加不必要的费用)运行宁。因此,我需要能够从实例本身内部调用该函数。
任何其他有助于实现我的目标的建议都将不胜感激。
我认为您必须允许完全访问作为服务帐户运行的实例上的所有云 API link。
然后将必要的角色分配给服务帐户以调用云函数(roles/cloudfunctions.invoker)。
To change scopes, in the Access scopes section, set the appropriate
scopes for your needs. As a best practice, specify only the access
scopes that your VM instance requires. If you're not sure of the
proper access scopes to set, choose Allow full access to all Cloud
APIs and then make sure to restrict access by setting IAM roles.
我正在尝试调用一个关闭 VM 实例的云函数:
gcloud functions call stopInstancePubSub --data '{"data":"<instance data in base64>"}'
当我从我的本地计算机或 gcloud 控制台 运行 它时,它工作得很好。但是我需要能够从实例本身内部 运行 它,当我尝试这样做时,这是抛出的错误:
ERROR: (gcloud.functions.call) ResponseError: status=[403], code=[Forbidden], message=[Request had insufficient authentication scopes.]
基本上,我希望能够将脚本安排到每天 运行(它会 运行 大约 2-3 小时)。因此,我使用云调度程序调用云函数,该函数每天凌晨 12 点启动脚本,并且可以正常工作,但我需要能够在脚本完成后关闭实例(以避免添加不必要的费用)运行宁。因此,我需要能够从实例本身内部调用该函数。
任何其他有助于实现我的目标的建议都将不胜感激。
我认为您必须允许完全访问作为服务帐户运行的实例上的所有云 API link。
然后将必要的角色分配给服务帐户以调用云函数(roles/cloudfunctions.invoker)。
To change scopes, in the Access scopes section, set the appropriate scopes for your needs. As a best practice, specify only the access scopes that your VM instance requires. If you're not sure of the proper access scopes to set, choose Allow full access to all Cloud APIs and then make sure to restrict access by setting IAM roles.