-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaf_demo.tf
115 lines (107 loc) · 3.54 KB
/
waf_demo.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
terraform {
required_providers {
volterra = {
source = "volterraedge/volterra"
version = "0.11.7"
}
}
}
provider "volterra" {
#api_p12_file = var.api_p12_file
#url = var.api_url
}
locals {
demoFQDN = "${var.custName}.${var.demoDomain}"
}
resource "volterra_app_firewall" "app_firewall" {
name = format("%s-app-firewall", var.demoNameSpace)
namespace = var.demoNameSpace
count = var.disableWAF ? 0 : 1
allow_all_response_codes = true
disable_anonymization = true
use_default_blocking_page = true
default_bot_setting = true
default_detection_settings = true
blocking = true
}
resource "volterra_healthcheck" "healthcheck" {
name = format("%s-healthcheck", var.custName)
namespace = var.demoNameSpace
http_health_check {
host_header = var.originFQDN
path = "/"
}
healthy_threshold = var.healthy_threshold
interval = var.interval
timeout = var.timeout
unhealthy_threshold = var.unhealthy_threshold
}
resource "volterra_origin_pool" "origin_pool" {
name = format("%s-origin-pool", var.custName)
namespace = var.demoNameSpace
endpoint_selection = "LOCAL_PREFERRED"
loadbalancer_algorithm = "LB_OVERRIDE"
healthcheck {
name = volterra_healthcheck.healthcheck.name
namespace = volterra_healthcheck.healthcheck.namespace
tenant = var.xcTenant
}
origin_servers {
public_name {
dns_name = var.originFQDN
}
}
port = 443
use_tls {
sni = var.originFQDN
no_mtls = true
volterra_trusted_ca = true
tls_config {
default_security = true
}
}
}
resource "volterra_http_loadbalancer" "http_lb" {
name = format("%s-https-lb", var.custName)
namespace = var.demoNameSpace
description = format("HTTPS Load balancer for %s domain", var.originFQDN )
domains = [format("%s", local.demoFQDN)]
advertise_on_public_default_vip = true
https_auto_cert {
add_hsts = false
http_redirect = true
no_mtls = true
}
default_route_pools {
pool {
name = volterra_origin_pool.origin_pool.name
namespace = volterra_origin_pool.origin_pool.namespace
}
}
dynamic "app_firewall" {
for_each = var.disableWAF ? [] : [1]
content {
name = var.disableWAF ? null : format("%s-app-firewall", var.demoNameSpace)
namespace = var.disableWAF ? null : var.demoNameSpace
tenant = var.disableWAF ? null : var.xcTenant
}
}
disable_waf = var.disableWAF
disable_rate_limit = true
round_robin = true
#service policy to apply
service_policies_from_namespace = var.servicePolicyType == "namespace" ? true : null
no_service_policies = var.servicePolicyType == "none" ? true : null
dynamic "active_service_policies" {
for_each = var.servicePolicyType == "custom" ? [1] : []
content {
policies {
name = format("%s-service-policy", var.custName)
namespace = var.demoNameSpace
tenant = var.xcTenant
}
}
}
#challenge
no_challenge = true
}