Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module "localhost_function" {
| description | The description of the function. | string | `"Processes events."` | no |
| entry\_point | The name of a method in the function source which will be invoked when the function is executed. | string | n/a | yes |
| environment\_variables | A set of key/value environment variable pairs to assign to the function. | map(string) | `<map>` | no |
| event\_trigger | A source that fires events in response to a condition in another service. | map(string) | n/a | yes |
| event\_trigger | A source that fires events in response to a condition in another service. | map(string) | `<map>` | no |
| event\_trigger\_failure\_policy\_retry | A toggle to determine if the function should be retried on failure. | bool | `"false"` | no |
| files\_to\_exclude\_in\_source\_dir | Specify files to ignore when reading the source_dir | list(string) | `<list>` | no |
| ingress\_settings | The ingress settings for the function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY. Changes to this field will recreate the cloud function. | string | `"ALLOW_ALL"` | no |
Expand All @@ -73,13 +73,15 @@ module "localhost_function" {
| source\_dependent\_files | A list of any Terraform created `local_file`s that the module will wait for before creating the archive. | object | `<list>` | no |
| source\_directory | The pathname of the directory which contains the function source code. | string | n/a | yes |
| timeout\_s | The amount of time in seconds allotted for the execution of the function. | number | `"60"` | no |
| trigger\_http | Wheter to use HTTP trigger instead of the event trigger. | bool | `"null"` | no |
| vpc\_connector | The VPC Network Connector that this cloud function can connect to. It should be set up as fully-qualified URI. The format of this field is projects/*/locations/*/connectors/*. | string | `"null"` | no |
| vpc\_connector\_egress\_settings | The egress settings for the connector, controlling what traffic is diverted through it. Allowed values are ALL_TRAFFIC and PRIVATE_RANGES_ONLY. If unset, this field preserves the previously set value. | string | `"null"` | no |

## Outputs

| Name | Description |
|------|-------------|
| https\_trigger\_url | URL which triggers function execution. |
| name | The name of the function. |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
15 changes: 10 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ resource "google_cloudfunctions_function" "main" {
timeout = var.timeout_s
entry_point = var.entry_point
ingress_settings = var.ingress_settings
trigger_http = var.trigger_http
vpc_connector_egress_settings = var.vpc_connector_egress_settings
vpc_connector = var.vpc_connector

event_trigger {
event_type = var.event_trigger["event_type"]
resource = var.event_trigger["resource"]
dynamic "event_trigger" {
for_each = var.trigger_http != null ? [] : [1]

failure_policy {
retry = var.event_trigger_failure_policy_retry
content {
event_type = var.event_trigger["event_type"]
resource = var.event_trigger["resource"]

failure_policy {
retry = var.event_trigger_failure_policy_retry
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ output "name" {
description = "The name of the function."
value = google_cloudfunctions_function.main.name
}

output "https_trigger_url" {
description = "URL which triggers function execution."
value = var.trigger_http != null ? google_cloudfunctions_function.main.https_trigger_url : ""
}
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ variable "environment_variables" {

variable "event_trigger" {
type = map(string)
default = {}
description = "A source that fires events in response to a condition in another service."
}

variable "trigger_http" {
type = bool
default = null
description = "Wheter to use HTTP trigger instead of the event trigger."
}

variable "labels" {
type = map(string)
default = {}
Expand Down