【问题标题】:Cloud Composer Service Account Scope For Running Services within GCP用于在 GCP 中运行服务的 Cloud Composer 服务帐户范围
【发布时间】:2021-08-13 15:25:59
【问题描述】:

我正在 Cloud Composer 中设置一个 DAG,它会触发许多 Clo​​ud Run 和 Cloud Function 服务。 Cloud Composer 环境中指定的服务帐户(用户创建的 SA)肯定有权调用 Cloud Run 和 Cloud Function 服务,但是 Cloud Run 函数给出以下错误:

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
)

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

【问题讨论】:

    标签: google-cloud-platform airflow google-cloud-composer


    【解决方案1】:

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

    添加一个 Google 签名的 OpenID Connect ID 令牌作为请求的一部分

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

    【讨论】:

    • 谢谢,我最终在 PythonOperator 任务而不是 SimpleHttpOperator 任务中使用您链接到的文档中的代码来生成令牌并调用 url。现在似乎工作得很好。
    猜你喜欢
    • 2021-01-18
    • 1970-01-01
    • 2020-10-21
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 2021-04-27
    • 2020-06-18
    • 2021-12-01
    相关资源
    最近更新 更多