Skip to content

Commit f091820

Browse files
authored
feat: Added timeout block in repository-function module (#99)
* 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.
1 parent 3e48faa commit f091820

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

examples/automatic-labelling-from-repository/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ module "repository_function" {
7171
project_id = var.project_id
7272
region = var.region
7373
source_repository_url = data.null_data_source.main.outputs["source_repository_url"]
74+
75+
timeouts = {
76+
update = "10m"
77+
}
7478
}
7579

7680
resource "null_resource" "wait_for_function" {

modules/repository-function/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ is a tested reference of how to use this submodule with the
3333
| service\_account\_email | The service account to run the function as. | `string` | `""` | no |
3434
| source\_repository\_url | The URL of the repository which contains the function source code. | `string` | n/a | yes |
3535
| timeout\_s | The amount of time in seconds allotted for the execution of the function. | `number` | `60` | no |
36+
| 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 |
3637
| trigger\_http | Wheter to use HTTP trigger instead of the event trigger. | `bool` | `null` | no |
3738
| 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 |
3839
| 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 |

modules/repository-function/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ resource "google_cloudfunctions_function" "main" {
4949
project = var.project_id
5050
region = var.region
5151
service_account_email = var.service_account_email
52+
53+
timeouts {
54+
create = lookup(var.timeouts, "create", "5m")
55+
update = lookup(var.timeouts, "update", "5m")
56+
delete = lookup(var.timeouts, "delete", "5m")
57+
}
5258
}

modules/repository-function/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,14 @@ variable "vpc_connector" {
116116
default = null
117117
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/*."
118118
}
119+
120+
variable "timeouts" {
121+
type = map(string)
122+
description = "Timeout setting to customize how long certain operations(create, update, delete) are allowed to take before being considered to have failed."
123+
default = {}
124+
validation {
125+
condition = !contains([for t in keys(var.timeouts) : contains(["create", "update", "delete"], t)], false)
126+
error_message = "Only create, update, delete timeouts can be specified."
127+
}
128+
}
129+

0 commit comments

Comments
 (0)