Skip to content

Commit 22ea30f

Browse files
Add httpFilterConfigs and httpFilterMetadata fields to route rules in URL maps. (#14097) (#23071)
[upstream:10a629e9b64c1090b18c9cb5a21eba0acb1db168] Signed-off-by: Modular Magician <[email protected]>
1 parent ebe467d commit 22ea30f

File tree

2 files changed

+262
-0
lines changed

2 files changed

+262
-0
lines changed

.changelog/14097.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `httpFilterConfigs` and `httpFilterMetadata` fields to `pathMatchers[].routeRules[]` in `google_compute_url_map` resource (beta)
3+
```

website/docs/r/compute_url_map.html.markdown

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,215 @@ resource "google_storage_bucket" "error" {
10811081
location = "US"
10821082
}
10831083
```
1084+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
1085+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=url_map_http_filter_configs&open_in_editor=main.tf" target="_blank">
1086+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
1087+
</a>
1088+
</div>
1089+
## Example Usage - Url Map Http Filter Configs
1090+
1091+
1092+
```hcl
1093+
resource "google_compute_url_map" "urlmap" {
1094+
provider = google-beta
1095+
name = "urlmap"
1096+
description = "Test for httpFilterConfigs in route rules"
1097+
default_service = google_compute_backend_service.default.id
1098+
1099+
host_rule {
1100+
hosts = ["mysite.com"]
1101+
path_matcher = "allpaths"
1102+
}
1103+
1104+
path_matcher {
1105+
name = "allpaths"
1106+
default_service = google_compute_backend_service.default.id
1107+
1108+
route_rules {
1109+
priority = 1
1110+
service = google_compute_backend_service.service-a.id
1111+
match_rules {
1112+
prefix_match = "/"
1113+
ignore_case = true
1114+
}
1115+
http_filter_configs {
1116+
filter_name = "envoy.wasm"
1117+
config_type_url = "type.googleapis.com/google.protobuf.Struct"
1118+
config = jsonencode({
1119+
name = "my-filter"
1120+
root_id = "my_root_id"
1121+
vm_config = {
1122+
vm_id = "my_vm_id"
1123+
runtime = "envoy.wasm.runtime.v8"
1124+
code = {
1125+
local = {
1126+
inline_string = "const WASM_BINARY = '...'"
1127+
}
1128+
}
1129+
}
1130+
})
1131+
}
1132+
}
1133+
}
1134+
1135+
test {
1136+
service = google_compute_backend_service.default.id
1137+
host = "mysite.com"
1138+
path = "/"
1139+
}
1140+
}
1141+
1142+
resource "google_compute_backend_service" "default" {
1143+
provider = google-beta
1144+
name = "default-backend"
1145+
port_name = "http"
1146+
protocol = "HTTP"
1147+
timeout_sec = 10
1148+
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
1149+
1150+
health_checks = [google_compute_health_check.default.id]
1151+
}
1152+
1153+
resource "google_compute_backend_service" "service-a" {
1154+
provider = google-beta
1155+
name = "service-a-backend"
1156+
port_name = "http"
1157+
protocol = "HTTP"
1158+
timeout_sec = 10
1159+
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
1160+
1161+
health_checks = [google_compute_health_check.default.id]
1162+
}
1163+
1164+
resource "google_compute_health_check" "default" {
1165+
provider = google-beta
1166+
name = "health-check"
1167+
http_health_check {
1168+
port = 80
1169+
}
1170+
}
1171+
```
1172+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
1173+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=url_map_http_filter_metadata&open_in_editor=main.tf" target="_blank">
1174+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
1175+
</a>
1176+
</div>
1177+
## Example Usage - Url Map Http Filter Metadata
1178+
1179+
1180+
```hcl
1181+
resource "google_compute_url_map" "urlmap" {
1182+
provider = google-beta
1183+
name = "urlmap"
1184+
description = "Test for httpFilterMetadata in route rules"
1185+
default_service = google_compute_backend_service.default.id
1186+
1187+
host_rule {
1188+
hosts = ["mysite.com"]
1189+
path_matcher = "allpaths"
1190+
}
1191+
1192+
path_matcher {
1193+
name = "allpaths"
1194+
default_service = google_compute_backend_service.default.id
1195+
1196+
route_rules {
1197+
priority = 1
1198+
service = google_compute_backend_service.service-a.id
1199+
match_rules {
1200+
prefix_match = "/"
1201+
ignore_case = true
1202+
}
1203+
http_filter_metadata {
1204+
filter_name = "envoy.wasm"
1205+
config_type_url = "type.googleapis.com/google.protobuf.Struct"
1206+
config = jsonencode({
1207+
fields = {
1208+
timeout = {
1209+
string_value = "30s"
1210+
}
1211+
retries = {
1212+
number_value = 3
1213+
}
1214+
debug = {
1215+
bool_value = true
1216+
}
1217+
}
1218+
})
1219+
}
1220+
}
1221+
route_rules {
1222+
priority = 2
1223+
service = google_compute_backend_service.service-b.id
1224+
match_rules {
1225+
prefix_match = "/api"
1226+
ignore_case = true
1227+
}
1228+
http_filter_metadata {
1229+
filter_name = "envoy.rate_limit"
1230+
config_type_url = "type.googleapis.com/google.protobuf.Struct"
1231+
config = jsonencode({
1232+
fields = {
1233+
requests_per_unit = {
1234+
number_value = 100
1235+
}
1236+
unit = {
1237+
string_value = "MINUTE"
1238+
}
1239+
}
1240+
})
1241+
}
1242+
}
1243+
}
1244+
1245+
test {
1246+
service = google_compute_backend_service.default.id
1247+
host = "mysite.com"
1248+
path = "/"
1249+
}
1250+
}
1251+
1252+
resource "google_compute_backend_service" "default" {
1253+
provider = google-beta
1254+
name = "default-backend"
1255+
port_name = "http"
1256+
protocol = "HTTP"
1257+
timeout_sec = 10
1258+
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
1259+
1260+
health_checks = [google_compute_health_check.default.id]
1261+
}
1262+
1263+
resource "google_compute_backend_service" "service-a" {
1264+
provider = google-beta
1265+
name = "service-a-backend"
1266+
port_name = "http"
1267+
protocol = "HTTP"
1268+
timeout_sec = 10
1269+
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
1270+
1271+
health_checks = [google_compute_health_check.default.id]
1272+
}
1273+
1274+
resource "google_compute_backend_service" "service-b" {
1275+
provider = google-beta
1276+
name = "service-b-backend"
1277+
port_name = "http"
1278+
protocol = "HTTP"
1279+
timeout_sec = 10
1280+
load_balancing_scheme = "INTERNAL_SELF_MANAGED"
1281+
1282+
health_checks = [google_compute_health_check.default.id]
1283+
}
1284+
1285+
resource "google_compute_health_check" "default" {
1286+
provider = google-beta
1287+
name = "health-check"
1288+
http_health_check {
1289+
port = 80
1290+
}
1291+
}
1292+
```
10841293

10851294
## Argument Reference
10861295

@@ -1950,6 +2159,22 @@ The following arguments are supported:
19502159
customErrorResponsePolicy specifies how the Load Balancer returns error responses when BackendService or BackendBucket responds with an error.
19512160
Structure is [documented below](#nested_path_matcher_path_matcher_route_rules_route_rules_custom_error_response_policy).
19522161

2162+
* `http_filter_configs` -
2163+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
2164+
Outbound route specific configuration for networkservices.HttpFilter resources enabled by Traffic Director.
2165+
httpFilterConfigs only applies for load balancers with loadBalancingScheme set to INTERNAL_SELF_MANAGED.
2166+
See ForwardingRule for more details.
2167+
Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.
2168+
Structure is [documented below](#nested_path_matcher_path_matcher_route_rules_route_rules_http_filter_configs).
2169+
2170+
* `http_filter_metadata` -
2171+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
2172+
Outbound route specific metadata supplied to networkservices.HttpFilter resources enabled by Traffic Director.
2173+
httpFilterMetadata only applies for load balancers with loadBalancingScheme set to INTERNAL_SELF_MANAGED.
2174+
See ForwardingRule for more details.
2175+
Not supported when the URL map is bound to a target gRPC proxy that has validateForProxyless field set to true.
2176+
Structure is [documented below](#nested_path_matcher_path_matcher_route_rules_route_rules_http_filter_metadata).
2177+
19532178

19542179
<a name="nested_path_matcher_path_matcher_route_rules_route_rules_header_action"></a>The `header_action` block supports:
19552180

@@ -2645,6 +2870,40 @@ The following arguments are supported:
26452870
The HTTP status code returned with the response containing the custom error content.
26462871
If overrideResponseCode is not supplied, the same response code returned by the original backend bucket or backend service is returned to the client.
26472872

2873+
<a name="nested_path_matcher_path_matcher_route_rules_route_rules_http_filter_configs"></a>The `http_filter_configs` block supports:
2874+
2875+
* `filter_name` -
2876+
(Optional)
2877+
Name of the networkservices.HttpFilter resource this configuration belongs to.
2878+
This name must be known to the xDS client. Example: envoy.wasm
2879+
2880+
* `config_type_url` -
2881+
(Optional)
2882+
The fully qualified versioned proto3 type url of the protobuf that the filter expects for its contextual settings,
2883+
for example: type.googleapis.com/google.protobuf.Struct
2884+
2885+
* `config` -
2886+
(Optional)
2887+
The configuration needed to enable the networkservices.HttpFilter resource.
2888+
The configuration must be YAML formatted and only contain fields defined in the protobuf identified in configTypeUrl
2889+
2890+
<a name="nested_path_matcher_path_matcher_route_rules_route_rules_http_filter_metadata"></a>The `http_filter_metadata` block supports:
2891+
2892+
* `filter_name` -
2893+
(Optional)
2894+
Name of the networkservices.HttpFilter resource this configuration belongs to.
2895+
This name must be known to the xDS client. Example: envoy.wasm
2896+
2897+
* `config_type_url` -
2898+
(Optional)
2899+
The fully qualified versioned proto3 type url of the protobuf that the filter expects for its contextual settings,
2900+
for example: type.googleapis.com/google.protobuf.Struct
2901+
2902+
* `config` -
2903+
(Optional)
2904+
The configuration needed to enable the networkservices.HttpFilter resource.
2905+
The configuration must be YAML formatted and only contain fields defined in the protobuf identified in configTypeUrl
2906+
26482907
<a name="nested_path_matcher_path_matcher_default_url_redirect"></a>The `default_url_redirect` block supports:
26492908

26502909
* `host_redirect` -

0 commit comments

Comments
 (0)