Skip to content
Merged
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
2 changes: 1 addition & 1 deletion modules/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This module creates `google_compute_backend_service` resource and its dependenci
|------|-------------|------|---------|:--------:|
| affinity\_cookie\_ttl\_sec | Lifetime of cookies in seconds if session\_affinity is GENERATED\_COOKIE. | `number` | `null` | no |
| backend\_bucket\_name | The name of GCS bucket which serves the traffic. | `string` | `""` | no |
| cdn\_policy | Cloud CDN configuration for this BackendService. | <pre>object({<br> cache_mode = optional(string)<br> signed_url_cache_max_age_sec = optional(string)<br> default_ttl = optional(number)<br> max_ttl = optional(number)<br> client_ttl = optional(number)<br> negative_caching = optional(bool)<br> serve_while_stale = optional(number)<br> bypass_cache_on_request_headers = optional(list(string))<br> negative_caching_policy = optional(object({<br> code = optional(number)<br> ttl = optional(number)<br> }))<br> cache_key_policy = optional(object({<br> include_host = optional(bool)<br> include_protocol = optional(bool)<br> include_query_string = optional(bool)<br> query_string_blacklist = optional(list(string))<br> query_string_whitelist = optional(list(string))<br> include_http_headers = optional(list(string))<br> include_named_cookies = optional(list(string))<br> }))<br> })</pre> | `{}` | no |
| cdn\_policy | Cloud CDN configuration for this BackendService. | <pre>object({<br> cache_mode = optional(string)<br> signed_url_cache_max_age_sec = optional(string)<br> default_ttl = optional(number)<br> max_ttl = optional(number)<br> client_ttl = optional(number)<br> negative_caching = optional(bool)<br> serve_while_stale = optional(number)<br> bypass_cache_on_request_headers = optional(list(string))<br> negative_caching_policy = optional(object({<br> code = optional(number)<br> ttl = optional(number)<br> }))<br> cache_key_policy = optional(object({<br> include_host = optional(bool)<br> include_protocol = optional(bool)<br> include_query_string = optional(bool)<br> query_string_blacklist = optional(list(string))<br> query_string_whitelist = optional(list(string))<br> include_http_headers = optional(list(string))<br> include_named_cookies = optional(list(string))<br> }))<br> })</pre> | <pre>{<br> "cache_mode": "CACHE_ALL_STATIC",<br> "client_ttl": 3600,<br> "default_ttl": 3600,<br> "max_ttl": 86400,<br> "signed_url_cache_max_age_sec": 0<br>}</pre> | no |
| compression\_mode | Compress text responses using Brotli or gzip compression. | `string` | `"DISABLED"` | no |
| connection\_draining\_timeout\_sec | Time for which instance will be drained (not accept new connections, but still work to finish started). | `number` | `null` | no |
| custom\_request\_headers | Headers that the HTTP/S load balancer should add to proxied requests. | `list(string)` | `[]` | no |
Expand Down
5 changes: 3 additions & 2 deletions modules/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

locals {
is_backend_bucket = var.backend_bucket_name != null && var.backend_bucket_name != ""
is_backend_bucket = var.backend_bucket_name != null && var.backend_bucket_name != ""
serverless_neg_backends = local.is_backend_bucket ? [] : var.serverless_neg_backends
}

resource "google_compute_backend_service" "default" {
Expand Down Expand Up @@ -161,7 +162,7 @@ resource "google_compute_backend_service" "default" {
}

resource "google_compute_region_network_endpoint_group" "serverless_negs" {
for_each = { for serverless_neg_backend in var.serverless_neg_backends :
for_each = { for serverless_neg_backend in local.serverless_neg_backends :
"neg-${var.name}-${serverless_neg_backend.service_name}-${serverless_neg_backend.region}" => serverless_neg_backend }


Expand Down
7 changes: 6 additions & 1 deletion modules/backend/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ spec:
include_named_cookies = optional(list(string))
}))
})
defaultValue: {}
defaultValue:
cache_mode: CACHE_ALL_STATIC
client_ttl: 3600
default_ttl: 3600
max_ttl: 86400
signed_url_cache_max_age_sec: 0
- name: outlier_detection
description: Settings controlling eviction of unhealthy hosts from the load balancing pool.
varType: |-
Expand Down
8 changes: 7 additions & 1 deletion modules/backend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ variable "cdn_policy" {
include_named_cookies = optional(list(string))
}))
})
default = {}
default = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • cdn_policy takes effect only if enable_cdn is set which is false by default.
  • Any user who have set enable_cdn would have already set cdn_policy as it is needed by backend_service. User defined cdn_policy will take effect.
  • The only impact would be if users have set enable_cdn with backend_bucket. The default behavior for cdn_policy would change.

We can mark this as breaking change.

cache_mode = "CACHE_ALL_STATIC"
default_ttl = 3600
client_ttl = 3600
max_ttl = 86400
signed_url_cache_max_age_sec = 0
}
}

variable "outlier_detection" {
Expand Down
2 changes: 1 addition & 1 deletion modules/frontend/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ spec:
connections:
- source:
source: github.com/terraform-google-modules/terraform-google-lb-http//modules/backend
version: ^12.0
version: ">= 12.0"
spec:
outputExpr: backend_service_info
- name: url_map_resource_uri
Expand Down