Skip to content

Commit 536c229

Browse files
committed
fix: make groups optional when using serverless_neg_backends
1 parent 231c762 commit 536c229

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

modules/serverless_negs/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ module "lb-http" {
5050
sample_rate = 1.0
5151
}
5252
53-
groups = [
53+
serverless_neg_backends = [
5454
{
55-
# Your serverless service should have a NEG created that's referenced here.
56-
group = google_compute_region_network_endpoint_group.default.id
55+
region = "us-central1"
56+
type = "cloud-run"
57+
service = {
58+
name = "your-cloud-run-service-name"
59+
version = "latest"
60+
}
5761
}
5862
]
5963

modules/serverless_negs/variables.tf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ variable "backends" {
6767
])
6868
error_message = "serverless_neg_backend type should be either 'cloud-run' or 'cloud-function' or 'app-engine'."
6969
}
70+
validation {
71+
condition = alltrue([
72+
for backend_key, backend_value in var.backends : (
73+
(backend_value.groups != null && backend_value.serverless_neg_backends == null) ||
74+
(backend_value.groups == null && backend_value.serverless_neg_backends != null)
75+
)])
76+
error_message = "Either groups or serverless_neg_backends should be provided."
77+
}
78+
7079
type = map(object({
7180
project = optional(string)
7281
protocol = optional(string)
@@ -84,20 +93,18 @@ variable "backends" {
8493
affinity_cookie_ttl_sec = optional(number)
8594
locality_lb_policy = optional(string)
8695

87-
8896
log_config = object({
8997
enable = optional(bool)
9098
sample_rate = optional(number)
9199
})
92100

93-
groups = list(object({
101+
groups = optional(list(object({
94102
group = string
95103
description = optional(string)
104+
})))
96105

97-
}))
98-
99-
// serverless_neg_backends is mutually exclusive to groups.There can only be one serverless neg per region
100-
// with one of cloud-run, cloud-functions and app-engine as service.
106+
// serverless_neg_backends is mutually exclusive to groups. There can only be one serverless NEG per region
107+
// with one of cloud-run, cloud-functions and app-engine as type.
101108
serverless_neg_backends = optional(list(object({
102109
region = string,
103110
type = string, // cloud-run, cloud-function and app-engine

0 commit comments

Comments
 (0)