Skip to content

Commit

Permalink
feat: Added timeout block in repository-function module (#99)
Browse files Browse the repository at this point in the history
* Added timeout block in repository-function module.

* add optional attribute to timeout object

* fix format errors

* add single block of timeouts

* add single block of timeouts

* removed experimental feature.
  • Loading branch information
fbeevikm authored Jul 22, 2022
1 parent 3e48faa commit f091820
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/automatic-labelling-from-repository/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ module "repository_function" {
project_id = var.project_id
region = var.region
source_repository_url = data.null_data_source.main.outputs["source_repository_url"]

timeouts = {
update = "10m"
}
}

resource "null_resource" "wait_for_function" {
Expand Down
1 change: 1 addition & 0 deletions modules/repository-function/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ is a tested reference of how to use this submodule with the
| service\_account\_email | The service account to run the function as. | `string` | `""` | no |
| source\_repository\_url | The URL of the repository 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 |
| timeouts | Timeout setting to customize how long certain operations(create, update, delete) are allowed to take before being considered to have failed. | `map(string)` | `{}` | 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 |
Expand Down
6 changes: 6 additions & 0 deletions modules/repository-function/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ resource "google_cloudfunctions_function" "main" {
project = var.project_id
region = var.region
service_account_email = var.service_account_email

timeouts {
create = lookup(var.timeouts, "create", "5m")
update = lookup(var.timeouts, "update", "5m")
delete = lookup(var.timeouts, "delete", "5m")
}
}
11 changes: 11 additions & 0 deletions modules/repository-function/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,14 @@ variable "vpc_connector" {
default = null
description = "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/*."
}

variable "timeouts" {
type = map(string)
description = "Timeout setting to customize how long certain operations(create, update, delete) are allowed to take before being considered to have failed."
default = {}
validation {
condition = !contains([for t in keys(var.timeouts) : contains(["create", "update", "delete"], t)], false)
error_message = "Only create, update, delete timeouts can be specified."
}
}

0 comments on commit f091820

Please sign in to comment.