GCP 中 运行 服务的 Cloud Composer 服务帐户范围

Cloud Composer Service Account Scope For Running Services within GCP

我正在 Cloud Composer 中设置一个 DAG,它会触发一些 Cloud 运行 和 Cloud Function 服务。 Cloud Composer Environment(用户创建的 SA)中指定的服务帐户绝对有权调用 Cloud 运行 和 Cloud Function 服务,但是 Cloud 运行 函数出现以下错误:

The request was not authenticated. Either allow unauthenticated invocations or set the proper Authorization header. Read more at https://cloud.google.com/run/docs/securing/authenticating

任务是这样的:

#t1 as request first report
big3_request = SimpleHttpOperator(
    task_id= "big3_request",
    method='GET',
    http_conn_id='trigger_cloud_run_service_conversions_big_3',
    endpoint='',
    response_check = lambda response: True if response == ("ok", 200) else False
)

我原以为 cloud composer 环境可以使用服务帐户 IAM 角色,但事实似乎并非如此。我需要在这里做什么才能启用 运行 的服务?看起来我可以将服务帐户的密钥文件添加到连接中,但我不明白如果在 CC 环境中使用相同的服务帐户,为什么有必要这样做?

您的服务(您在 Cloud Composer 中的 SimpleHttpOperator 任务 运行)需要在请求中提供身份验证凭据。更准确地说,它需要

add a Google-signed OpenID Connect ID token as part of the request

您可以找到 here in the official Google doc 提供此类令牌的不同方法以及对您的云 运行 服务端点的正确请求。