Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trigger_topic not working on terraform resource google_cloudfunctions_function

I have the following resource defined for terraform to create a cloud function. I want to be able to get it triggered thru a pubsub message.
which one of the block do I use ? event_trigger or trigger_topic

resource "google_cloudfunctions_function" "function" {

    name                      = var.appname
    entry_point               = "entry"
    available_memory_mb       = 128
    timeout                   = 120
    project                   = var.gcpproject
    region                    = var.region
    #trigger_topic             = "projects/${var.gcpproject}/topics/cloud-builds-topic"**
    source_archive_bucket     = var.google_storage_bucket
    source_archive_object     = "code/${var.appname}.zip"
    runtime     = "python3.7"
   #event_trigger = {
   #   event_type= "google.pubsub.topic.publish"
   #   resource= "projects/${var.gcpproject}/topics/cloud-builds-topic"
   #   service= "pubsub.googleapis.com"
   #   failure_policy= {}
   # }
}

When i use trigger_topic, it errors with

Error: Unsupported argument

  on main.tf line 12, in resource "google_cloudfunctions_function" "function":
  12:     trigger_topic             = "projects/${var.gcpproject}/topics/cloud-builds-topic"

An argument named "trigger_topic" is not expected here.

and when i use event_trigger, it errors with

Error: Unsupported argument

  on main.tf line 16, in resource "google_cloudfunctions_function" "function":
  16:     event_trigger = {

An argument named "event_trigger" is not expected here. Did you mean to define
a block of type "event_trigger"?
like image 794
Priyesh Patel Avatar asked Sep 01 '25 20:09

Priyesh Patel


1 Answers

There is no such attribute nor block as trigger_topic in google_cloudfunctions_function.

event_trigger should be a block, not a map (no =):

   event_trigger {
      event_type= "google.pubsub.topic.publish"
      resource= "projects/${var.gcpproject}/topics/cloud-builds-topic"
      service= "pubsub.googleapis.com"
      #failure_policy= {}
   }

failure_policy is also a block, not a map. service does not seem to be a correct attribute in the event_trigger block. Please double check documentation on valid attributes and blocks.

like image 121
Marcin Avatar answered Sep 03 '25 13:09

Marcin