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"?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With