File tree Expand file tree Collapse file tree 3 files changed +8
-71
lines changed
terraform/modules/cdn-glb Expand file tree Collapse file tree 3 files changed +8
-71
lines changed Original file line number Diff line number Diff line change @@ -6,59 +6,6 @@ resource "google_compute_security_policy" "security_policy" {
66 type = " CLOUD_ARMOR"
77}
88
9- # Deny non-GET methods - priority 2147483625
10- resource "google_compute_security_policy_rule" "deny_non_get" {
11- security_policy = google_compute_security_policy. security_policy . name
12- project = var. project
13- action = " deny(403)"
14- priority = 2147483625
15- preview = false
16- description = " Deny non-GET methods"
17-
18- match {
19- expr {
20- expression = " request.method.upper() != 'GET'"
21- }
22- }
23- }
24-
25- # Block requests except whitelisted hosts - priority 2147483635
26- resource "google_compute_security_policy_rule" "block_non_whitelisted_hosts" {
27- security_policy = google_compute_security_policy. security_policy . name
28- project = var. project
29- action = " deny(403)"
30- priority = 2147483635
31- preview = false
32- description = " Block requests except whitelisted hosts"
33-
34- match {
35- expr {
36- expression = " request.headers['host'].lower() != '${ var . domain } '"
37- }
38- }
39- }
40-
41- # Blacklisted user-agents - priority 2147483640
42- resource "google_compute_security_policy_rule" "block_user_agents" {
43- security_policy = google_compute_security_policy. security_policy . name
44- project = var. project
45- action = " deny(403)"
46- priority = 2147483640
47- preview = false
48- description = " Black-listed user-agents"
49-
50- match {
51- expr {
52- expression = <<- EOT
53- has(request.headers['user-agent']) && (
54- request.headers['user-agent'].contains('GenomeCrawler') ||
55- request.headers['user-agent'].contains('AhrefsBot')
56- )
57- EOT
58- }
59- }
60- }
61-
629# Default rate limiting rule - priority 2147483646
6310resource "google_compute_security_policy_rule" "rate_limit" {
6411 security_policy = google_compute_security_policy. security_policy . name
Original file line number Diff line number Diff line change @@ -28,9 +28,6 @@ resource "google_compute_backend_service" "backend" {
2828 for_each = var. enable_cdn ? [1 ] : []
2929 content {
3030 cache_mode = var. cdn_cache_mode
31- default_ttl = var. cdn_default_ttl
32- max_ttl = var. cdn_max_ttl
33- client_ttl = var. cdn_client_ttl
3431 serve_while_stale = var. cdn_serve_while_stale
3532 negative_caching = var. cdn_negative_caching
3633 signed_url_cache_max_age_sec = 0
@@ -84,6 +81,10 @@ resource "google_compute_managed_ssl_certificate" "ssl_cert" {
8481 managed {
8582 domains = [var . domain ]
8683 }
84+
85+ lifecycle {
86+ prevent_destroy = true
87+ }
8788}
8889
8990# HTTPS Target Proxy
@@ -93,6 +94,10 @@ resource "google_compute_target_https_proxy" "https_proxy" {
9394 url_map = google_compute_url_map. url_map . id
9495 ssl_certificates = [google_compute_managed_ssl_certificate . ssl_cert . id ]
9596 quic_override = " ENABLE"
97+
98+ lifecycle {
99+ prevent_destroy = true
100+ }
96101}
97102
98103
Original file line number Diff line number Diff line change @@ -40,21 +40,6 @@ variable "cdn_cache_mode" {
4040 type = string
4141 default = " USE_ORIGIN_HEADERS"
4242}
43- variable "cdn_default_ttl" {
44- description = " Default TTL for cached content in seconds"
45- type = number
46- default = 2592000 # 30 days
47- }
48- variable "cdn_max_ttl" {
49- description = " Maximum TTL for cached content in seconds"
50- type = number
51- default = 2592000 # 30 days
52- }
53- variable "cdn_client_ttl" {
54- description = " Client TTL for cached content in seconds (browser cache)"
55- type = number
56- default = 3600 # 1 hour
57- }
5843variable "cdn_serve_while_stale" {
5944 description = " Time to serve stale content while revalidating in seconds"
6045 type = number
You can’t perform that action at this time.
0 commit comments