Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/serverless_negs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ module "lb-http" {
sample_rate = 1.0
}

groups = [
serverless_neg_backends = [
{
# Your serverless service should have a NEG created that's referenced here.
group = google_compute_region_network_endpoint_group.default.id
region = "us-central1"
type = "cloud-run"
service = {
name = "your-cloud-run-service-name"
version = "latest"
}
}
]

Expand Down
19 changes: 13 additions & 6 deletions modules/serverless_negs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ variable "backends" {
])
error_message = "serverless_neg_backend type should be either 'cloud-run' or 'cloud-function' or 'app-engine'."
}
validation {
condition = alltrue([
for backend_key, backend_value in var.backends : (
(backend_value.groups != null && backend_value.serverless_neg_backends == null) ||
(backend_value.groups == null && backend_value.serverless_neg_backends != null)
)])
error_message = "Either groups or serverless_neg_backends should be provided."
}

type = map(object({
project = optional(string)
protocol = optional(string)
Expand All @@ -84,20 +93,18 @@ variable "backends" {
affinity_cookie_ttl_sec = optional(number)
locality_lb_policy = optional(string)


log_config = object({
enable = optional(bool)
sample_rate = optional(number)
})

groups = list(object({
groups = optional(list(object({
group = string
description = optional(string)
})))

}))

// serverless_neg_backends is mutually exclusive to groups.There can only be one serverless neg per region
// with one of cloud-run, cloud-functions and app-engine as service.
// serverless_neg_backends is mutually exclusive to groups. There can only be one serverless NEG per region
// with one of cloud-run, cloud-functions and app-engine as type.
serverless_neg_backends = optional(list(object({
region = string,
type = string, // cloud-run, cloud-function and app-engine
Expand Down