From 09fd1b6803e63e88567c145eee448ababefc1e38 Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Thu, 29 Dec 2022 23:53:38 +0000 Subject: [PATCH 1/2] fix: set optional max_instances to default --- examples/automatic-labelling-folder/main.tf | 1 + .../main.tf | 1 + .../main.tf | 7 ++++--- examples/delete-vms-without-cmek/main.tf | 1 + examples/dynamic-files/main.tf | 1 + modules/repository-function/README.md | 1 + modules/repository-function/main.tf | 1 + modules/repository-function/variables.tf | 5 +++++ test/setup/versions.tf | 19 +++++++++++-------- 9 files changed, 26 insertions(+), 11 deletions(-) diff --git a/examples/automatic-labelling-folder/main.tf b/examples/automatic-labelling-folder/main.tf index 660131a..5449889 100644 --- a/examples/automatic-labelling-folder/main.tf +++ b/examples/automatic-labelling-folder/main.tf @@ -50,6 +50,7 @@ module "localhost_function" { region = var.region source_directory = "${path.module}/function_source" runtime = "nodejs10" + max_instances = 3000 } resource "null_resource" "wait_for_function" { diff --git a/examples/automatic-labelling-from-localhost/main.tf b/examples/automatic-labelling-from-localhost/main.tf index b02fba0..76282e4 100644 --- a/examples/automatic-labelling-from-localhost/main.tf +++ b/examples/automatic-labelling-from-localhost/main.tf @@ -42,6 +42,7 @@ module "localhost_function" { region = var.region source_directory = "${path.module}/function_source" runtime = "nodejs10" + max_instances = 3000 } resource "null_resource" "wait_for_function" { diff --git a/examples/automatic-labelling-from-repository/main.tf b/examples/automatic-labelling-from-repository/main.tf index 0587fe6..72d6625 100644 --- a/examples/automatic-labelling-from-repository/main.tf +++ b/examples/automatic-labelling-from-repository/main.tf @@ -58,9 +58,10 @@ module "event_project_log_entry" { module "repository_function" { source = "../../modules/repository-function" - description = "Labels resource with owner information." - entry_point = "labelResource" - runtime = "nodejs10" + description = "Labels resource with owner information." + entry_point = "labelResource" + runtime = "nodejs10" + max_instances = 3000 environment_variables = { LABEL_KEY = "principal-email" diff --git a/examples/delete-vms-without-cmek/main.tf b/examples/delete-vms-without-cmek/main.tf index 7f012ce..d7e54e3 100644 --- a/examples/delete-vms-without-cmek/main.tf +++ b/examples/delete-vms-without-cmek/main.tf @@ -52,4 +52,5 @@ module "localhost_function" { project_id = var.project_id region = var.region source_directory = "${path.module}/function_source" + max_instances = 3000 } diff --git a/examples/dynamic-files/main.tf b/examples/dynamic-files/main.tf index 1e12d6e..5b12836 100644 --- a/examples/dynamic-files/main.tf +++ b/examples/dynamic-files/main.tf @@ -97,6 +97,7 @@ module "localhost_function" { region = var.region source_directory = "${path.module}/function_source" runtime = "nodejs10" + max_instances = 3000 source_dependent_files = [local_file.file] depends_on = [google_secret_manager_secret_version.secret_key_version] diff --git a/modules/repository-function/README.md b/modules/repository-function/README.md index 2a66003..6b6051f 100644 --- a/modules/repository-function/README.md +++ b/modules/repository-function/README.md @@ -26,6 +26,7 @@ is a tested reference of how to use this submodule with the | event\_trigger\_failure\_policy\_retry | A toggle to determine if the function should be retried on failure. | `bool` | `false` | 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 | | labels | A set of key/value label pairs to assign to any lableable resources. | `map(string)` | `{}` | no | +| max\_instances | The maximum number of parallel executions of the function. | `number` | `null` | no | | name | The name to apply to any nameable resources. | `string` | n/a | yes | | project\_id | The ID of the project to which resources will be applied. | `string` | n/a | yes | | region | The region in which resources will be applied. | `string` | n/a | yes | diff --git a/modules/repository-function/main.tf b/modules/repository-function/main.tf index 3c441fb..c466fdc 100644 --- a/modules/repository-function/main.tf +++ b/modules/repository-function/main.tf @@ -18,6 +18,7 @@ resource "google_cloudfunctions_function" "main" { name = var.name description = var.description available_memory_mb = var.available_memory_mb + max_instances = var.max_instances timeout = var.timeout_s entry_point = var.entry_point ingress_settings = var.ingress_settings diff --git a/modules/repository-function/variables.tf b/modules/repository-function/variables.tf index d3ee304..236557d 100644 --- a/modules/repository-function/variables.tf +++ b/modules/repository-function/variables.tf @@ -127,3 +127,8 @@ variable "timeouts" { } } +variable "max_instances" { + type = number + default = null + description = "The maximum number of parallel executions of the function." +} diff --git a/test/setup/versions.tf b/test/setup/versions.tf index a031ed0..97928a0 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -15,13 +15,16 @@ */ terraform { - required_version = ">= 0.12" -} - -provider "google" { - version = ">= 3.53.0, < 5.0" -} + required_version = ">= 0.13" + required_providers { -provider "google-beta" { - version = ">= 3.53.0, < 5.0" + google = { + source = "hashicorp/google" + version = ">= 3.53.0, < 5.0" + } + google-beta = { + source = "hashicorp/google-beta" + version = ">= 3.53.0, < 5.0" + } + } } From 610c373a596784e1dca55d55ab37833f645084be Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Thu, 5 Jan 2023 19:51:34 +0000 Subject: [PATCH 2/2] remove beta provider --- test/setup/versions.tf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/setup/versions.tf b/test/setup/versions.tf index 97928a0..8099918 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -22,9 +22,5 @@ terraform { source = "hashicorp/google" version = ">= 3.53.0, < 5.0" } - google-beta = { - source = "hashicorp/google-beta" - version = ">= 3.53.0, < 5.0" - } } }