diff --git a/google_fastly_waf/README.md b/google_fastly_waf/README.md index 023282f1..3d8387fd 100644 --- a/google_fastly_waf/README.md +++ b/google_fastly_waf/README.md @@ -142,17 +142,25 @@ module "fastly_stage" { |------|-------------|------|---------|:--------:| | [application](#input\_application) | Application name | `string` | n/a | yes | | [backends](#input\_backends) | A list of backends | `list(any)` | `[]` | no | +| [cache\_header](#input\_cache\_header) | A cache header to check to toggle cache lookup | `string` | `""` | no | +| [cache\_settings](#input\_cache\_settings) | List of cache settings for the Fastly service. |
list(object({
name = string
action = optional(string)
cache_condition = optional(string)
stale_ttl = optional(number)
ttl = optional(number)
}))
| `[]` | no | | [conditions](#input\_conditions) | List of Fastly conditions to create (REQUEST, RESPONSE or CACHE). |
list(object({
name = string # required, unique
statement = string # VCL conditional expression
type = string # one of: REQUEST, RESPONSE, CACHE
priority = optional(number) # lower runs first, default 10
}))
| `[]` | no | | [domains](#input\_domains) | A list of domains | `list(any)` | `[]` | no | | [environment](#input\_environment) | The environment this module is deployed into | `string` | n/a | yes | +| [https\_redirect\_enabled](#input\_https\_redirect\_enabled) | n/a | `bool` | `true` | no | +| [log\_sampling\_enabled](#input\_log\_sampling\_enabled) | n/a | `bool` | `false` | no | +| [log\_sampling\_percent](#input\_log\_sampling\_percent) | n/a | `string` | `"10"` | no | | [ngwaf\_agent\_level](#input\_ngwaf\_agent\_level) | This is the site wide blocking level | `string` | `"log"` | no | | [ngwaf\_immediate\_block](#input\_ngwaf\_immediate\_block) | n/a | `bool` | `true` | no | +| [ngwaf\_percent\_enabled](#input\_ngwaf\_percent\_enabled) | n/a | `number` | `100` | no | | [project\_id](#input\_project\_id) | The GCP project\_ id for BigQuery logging | `string` | n/a | yes | | [realm](#input\_realm) | The realm this module is deployed into | `string` | n/a | yes | | [response\_objects](#input\_response\_objects) | List of synthetic response objects to attach to the Fastly service. |
list(object({
name = string # required
status = optional(number) # e.g. 503
response = optional(string) # e.g. "Ok"
content = optional(string)
content_type = optional(string)
request_condition = optional(string) # name of an existing REQUEST condition
cache_condition = optional(string) # name of an existing CACHE condition
}))
| `[]` | no | +| [service\_account](#input\_service\_account) | n/a | `string` | `null` | no | | [snippets](#input\_snippets) | snippets | `list(any)` | `[]` | no | | [stage](#input\_stage) | Determine if something should be deployed to stage | `bool` | `false` | no | | [subscription\_domains](#input\_subscription\_domains) | Domains to issue SSL certificates for | `list(any)` | `[]` | no | +| [subscription\_domains\_force\_update](#input\_subscription\_domains\_force\_update) | Force update the subscription even if it has active domains. Warning: this can disable production traffic if used incorrectly. | `bool` | `false` | no | ## Outputs diff --git a/google_fastly_waf/main.tf b/google_fastly_waf/main.tf index 73108598..ff2f26e5 100644 --- a/google_fastly_waf/main.tf +++ b/google_fastly_waf/main.tf @@ -202,7 +202,8 @@ resource "fastly_service_vcl" "default" { { realm = var.realm, environment = var.environment, - https_redirect_enabled = var.https_redirect_enabled + https_redirect_enabled = var.https_redirect_enabled, + cache_header = var.cache_header } ) main = true diff --git a/google_fastly_waf/variables.tf b/google_fastly_waf/variables.tf index 7f83c255..e2af3459 100644 --- a/google_fastly_waf/variables.tf +++ b/google_fastly_waf/variables.tf @@ -111,6 +111,12 @@ variable "https_redirect_enabled" { default = true } +variable "cache_header" { + type = string + default = "" + description = "A cache header to check to toggle cache lookup" +} + ## NGWAF variable "ngwaf_agent_level" { type = string diff --git a/google_fastly_waf/vcl/main.vcl.tftpl b/google_fastly_waf/vcl/main.vcl.tftpl index a1f27cc7..c164ef0f 100644 --- a/google_fastly_waf/vcl/main.vcl.tftpl +++ b/google_fastly_waf/vcl/main.vcl.tftpl @@ -28,10 +28,13 @@ if (fastly.ff.visits_this_service == 0 && req.restarts == 0) { set req.http.ohfp = fastly_info.oh_fingerprint; } + +%{ if length(cache_header) > 0 } # If a header is set return caching -if (req.http.X-Cache-Request == "true") { +if (req.http.${cache_header} == "true") { return(lookup); } +%{ endif } # Default: pass through no caching return(pass);