簡體   English   中英

使用 Eventarc 創建一個目標為雲函數的 terraform

[英]Creating a terraform with Eventarc with its destination to cloud function

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/eventarc_trigger

我一直在尋找創建一個 terraform 文件來幫助部署一個 eventarc,並將其目標作為雲函數。 在 terraform 文檔上,它表示無法配置。 這是否意味着我只能部署具有通用雲功能的 eventarc,並且需要通過 GUI 配置其余部分? 或者我可以嘗試通過 Terraform 完全部署它的另一種解決方案嗎?

或者我可以嘗試通過 Terraform 部署雲功能來創建它嗎? 如果是這樣,我將如何為 eventarc 編寫 event_trigger 塊? 下面我猜會是什么?

resource "google_cloudfunctions_function" "cloudfunc-name" {
  name        = "cloudfunc-name"
  description = "cloud func desc"
  runtime     = "python39"
  project     = "googleproject"
  region      = "us-central1"
  available_memory_mb   = 256
  max_instances         = 10
  timeout                = 300
  entry_point = "helloworld_entry"
  source_archive_bucket = "filepath_to_bucket"
  source_archive_object = google_storage_bucket_object.function_zip_bucket_object.name

  event_trigger {
    event_type = "google.cloud.audit.log.v1.written"
    event = "google.cloud.bigquery.v2.TableService.InsertTable"
    receive_event = "us-central1"
    service_account = "someserviceaccount@gserviceaccount.com"
    failure_policy {
      retry = false
    }
  }

Eventarc 只能觸發Cloud Functions 2nd generation 為什么? 因為第二代 Cloud Functions 以 Cloud Run 為后盾。

因此,您必須使用第二代 terraform 模塊來部署您的函數,然后使用 eventarc 上的 Cloud Functions 部分。 我最近沒有測試。 在任何情況下,如果它不適用於事件弧上的 Cloud Functions 配置,您可以將其替換為 Cloud Run 配置(提供函數名稱(也是 Cloud Run 服務的名稱))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM