https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/eventarc_trigger
I was looking to create a terraform file to help deploy an eventarc with its destination as a cloud function. On the terraform docs it says it was not available to configure. Does this mean I can only deploy the eventarc with a generic cloud function and would need to configure the rest through the GUI? Or is there another solution I can try to fully deploy it through terraform?
Or maybe can I try to create it through deploying a cloud function through terraform? If so how would I code the event_trigger block for the eventarc? Below I am guessing what it would be?
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 = "[email protected]"
failure_policy {
retry = false
}
}
Eventarc can only trigger Cloud Functions 2nd generation. Why? Because Cloud Functions 2nd gen is backed on Cloud Run.
So, you have to use the 2nd gen terraform module to deploy your function and then use the Cloud Functions section on the eventarc. I didn't test recently. In any cases, if it don't work with the Cloud Functions config on event arc, you can replace it with Cloud Run config (provide the name of the functions (which is the name of the Cloud Run service also))