Skip to content

Commit 6376223

Browse files
committed
feat: parameterize Cloud Run functions available CPU
1 parent addd81e commit 6376223

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

terraform/modules/autoscaler-functions/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ resource "google_cloudfunctions2_function" "poller_function" {
120120

121121
service_config {
122122
available_memory = "256M"
123+
available_cpu = var.poller_function_available_cpu
123124
ingress_settings = "ALLOW_INTERNAL_AND_GCLB"
124125
service_account_email = var.poller_sa_email
125126
}
@@ -157,6 +158,7 @@ resource "google_cloudfunctions2_function" "scaler_function" {
157158

158159
service_config {
159160
available_memory = "256M"
161+
available_cpu = var.scaler_function_available_cpu
160162
ingress_settings = "ALLOW_INTERNAL_AND_GCLB"
161163
service_account_email = var.scaler_sa_email
162164
}

terraform/modules/autoscaler-functions/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,23 @@ variable "forwarder_sa_emails" {
5555
// Example ["serviceAccount:[email protected]"]
5656
default = []
5757
}
58+
59+
variable "poller_function_available_cpu" {
60+
type = number
61+
default = null
62+
description = "The amount of available CPU for the poller function. Unset/null will allow Cloud Run to default based on Memory."
63+
validation {
64+
condition = var.poller_function_available_cpu == null ? true : var.poller_function_available_cpu >= 0.08
65+
error_message = "The minimum value for poller_function_available_cpu is 0.08."
66+
}
67+
}
68+
69+
variable "scaler_function_available_cpu" {
70+
type = number
71+
default = null
72+
description = "The amount of available CPU for the scaler function. Unset/null will allow Cloud Run to default based on Memory."
73+
validation {
74+
condition = var.scaler_function_available_cpu == null ? true : var.scaler_function_available_cpu >= 0.08
75+
error_message = "The minimum value for scaler_function_available_cpu is 0.08."
76+
}
77+
}

0 commit comments

Comments
 (0)