Skip to content

Commit

Permalink
Merge pull request #29 from NandosUK/custom-event-type
Browse files Browse the repository at this point in the history
testing dynamic trigger
  • Loading branch information
audronFS authored Oct 5, 2023
2 parents 1420cb0 + 6bb909e commit aafd831
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
19 changes: 19 additions & 0 deletions gcp/cloud-function-gen2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ resource "google_cloudfunctions2_function" "function" {
}
}

dynamic "event_trigger" {
for_each = var.event_trigger != null ? [var.event_trigger] : []
content {
trigger_region = var.region
event_type = event_trigger.value["event_type"]
retry_policy = event_trigger.value["retry_policy"]
service_account_email = event_trigger.value["service_account_email"]
dynamic "event_filters" {
for_each = event_trigger.value["event_filters"]

content {
attribute = event_filters.value["attribute"]
value = event_filters.value["value"]
operator = event_filters.value["operator"]
}
}
}
}

build_config {
runtime = var.function_runtime != "" ? var.function_runtime : local.language_config.default_runtime
entry_point = var.function_entry_point != "" ? var.function_entry_point : local.language_config.default_entry_point
Expand Down
20 changes: 16 additions & 4 deletions gcp/cloud-function-gen2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,27 @@ variable "function_type" {}
variable "threshold_value" {
default = 60
}
variable "event_trigger" {
description = "event trigger, per resource docs"
default = null
}

variable "event_type" {
default = null
}

variable "event_trigger" {
description = "List of event triggers"
type = object({
trigger_region = string
event_type = string
retry_policy = string
service_account_email = string
event_filters = list(object({
attribute = string
value = string
operator = optional(string)
}))
})
default = null
}

variable "schedule" {
type = object({
cron = string
Expand Down

0 comments on commit aafd831

Please sign in to comment.