FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 1dd59d62 authored by Dave Hart's avatar Dave Hart :pizza:
Browse files

feat: add `available_cpu` variable

Add `available_cpu` variable for specifying the number of CPUs to allocate to
the Cloud Function.

Add validation checks for the variables `available_cpu`, `available_memory_mb`
and `timeout`.

Closes #14
parent 966c9b56
No related branches found
No related tags found
1 merge request!17feat: add `available_cpu` variable
Pipeline #577277 passed
......@@ -149,7 +149,8 @@ environment variable.
| <a name="input_alert_notification_channels"></a> [alert\_notification\_channels](#input\_alert\_notification\_channels) | A list of notification channel IDs to send alerts to. The format for the channel IDs should<br> be as follows.<br><br> [<br> "projects/[PROJECT\_ID]/notificationChannels/[CHANNEL\_ID]"<br> ] | `list(string)` | `[]` | no |
| <a name="input_alert_success_period"></a> [alert\_success\_period](#input\_alert\_success\_period) | Period over which 'alert\_success\_threshold' is used. Default: "3600s" which<br>is one hour. | `string` | `"3600s"` | no |
| <a name="input_alert_success_threshold"></a> [alert\_success\_threshold](#input\_alert\_success\_threshold) | The minimum number of successes within 'alert\_success\_period' below which an<br>alert is fired. | `number` | `5` | no |
| <a name="input_available_memory_mb"></a> [available\_memory\_mb](#input\_available\_memory\_mb) | Maxiumum memory available to the script in MiB. Default: 128 MiB. | `number` | `128` | no |
| <a name="input_available_cpu"></a> [available\_cpu](#input\_available\_cpu) | Maxiumum number of CPUs available to the script. See<br>https://cloud.google.com/functions/docs/configuring/memory for valid<br>values.<br><br>When this value is set, `available_memory_mb` must also be specified.<br>Otherwise, the default is based on the value of `available_memory_mb`. | `number` | n/a | yes |
| <a name="input_available_memory_mb"></a> [available\_memory\_mb](#input\_available\_memory\_mb) | Maxiumum memory available to the script in MiB. See<br>https://cloud.google.com/functions/docs/configuring/memory for valid<br>values. Default: 128 MiB. | `number` | `128` | no |
| <a name="input_description"></a> [description](#input\_description) | Longer human-friendly description of the script | `string` | `""` | no |
| <a name="input_enable_versioning"></a> [enable\_versioning](#input\_enable\_versioning) | The bucket's versioning configuration.<br>While set to true, versioning is fully enabled for the bucket. | `bool` | `true` | no |
| <a name="input_entry_point"></a> [entry\_point](#input\_entry\_point) | Entrypoint to script. Defaults to 'main'. | `string` | `"main"` | no |
......
......@@ -137,6 +137,7 @@ resource "google_cloudfunctions2_function" "script" {
service_config {
timeout_seconds = var.timeout
service_account_email = local.service_account_email
available_cpu = var.available_cpu
available_memory = "${var.available_memory_mb}Mi"
max_instance_count = 1
......
......@@ -90,14 +90,54 @@ variable "timeout" {
Maximum time, in seconds, that a script can take to execute. Invocations
which take longer than this fail. Default: 120 seconds.
EOT
validation {
condition = var.timeout > 0 && var.timeout <= 3600
error_message = "The `timeout` value must be > 0 and <= 3600 seconds."
}
}
variable "available_cpu" {
type = number
description = <<-EOT
Maxiumum number of CPUs available to the script. See
https://cloud.google.com/functions/docs/configuring/memory for valid
values.
When this value is set, `available_memory_mb` must also be specified.
Otherwise, the default is based on the value of `available_memory_mb`.
EOT
validation {
condition = contains(
[0.083, 0.167, 0.333, 0.583, 1, 2, 4, 8], var.available_cpu
)
error_message = <<-EOT
The `available_cpu` value must be valid. See
https://cloud.google.com/functions/docs/configuring/memory
EOT
}
}
variable "available_memory_mb" {
type = number
default = 128
description = <<-EOT
Maxiumum memory available to the script in MiB. Default: 128 MiB.
Maxiumum memory available to the script in MiB. See
https://cloud.google.com/functions/docs/configuring/memory for valid
values. Default: 128 MiB.
EOT
validation {
condition = contains(
[128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],
var.available_memory_mb
)
error_message = <<-EOT
The `available_memory_mb` value must be valid. See
https://cloud.google.com/functions/docs/configuring/memory
EOT
}
}
variable "alert_email_addresses" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment