Skip to content

Commit ec23f5f

Browse files
Add Mirror Percent to request_mirror_policy in URLMAP (#13974) (#22961)
[upstream:3c26542473e161f238082470c8cf00560e0ac8f5] Signed-off-by: Modular Magician <[email protected]>
1 parent 821c8a6 commit ec23f5f

File tree

2 files changed

+283
-0
lines changed

2 files changed

+283
-0
lines changed

.changelog/13974.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 `mirrorPercent` field to `requestMirrorPolicy` in `defaultRouteAction`, `pathMatchers[].defaultRouteAction`, `pathMatchers[].pathRules[].routeAction`, and `pathMatchers[].routeRules[].routeAction` to `google_compute_url_map` resource (beta)
3+
```

website/docs/r/compute_url_map.html.markdown

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,266 @@ resource "google_compute_http_health_check" "default" {
640640
timeout_sec = 1
641641
}
642642
```
643+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
644+
<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_default_mirror_percent&open_in_editor=main.tf" target="_blank">
645+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
646+
</a>
647+
</div>
648+
## Example Usage - Url Map Default Mirror Percent
649+
650+
651+
```hcl
652+
resource "google_compute_url_map" "urlmap" {
653+
provider = google-beta
654+
name = "urlmap"
655+
description = "Test for default route action mirror percent"
656+
657+
default_service = google_compute_backend_service.home.id
658+
659+
default_route_action {
660+
request_mirror_policy {
661+
backend_service = google_compute_backend_service.mirror.id
662+
mirror_percent = 50.0
663+
}
664+
}
665+
666+
host_rule {
667+
hosts = ["mysite.com"]
668+
path_matcher = "allpaths"
669+
}
670+
671+
path_matcher {
672+
name = "allpaths"
673+
default_service = google_compute_backend_service.home.id
674+
}
675+
}
676+
677+
resource "google_compute_backend_service" "home" {
678+
provider = google-beta
679+
name = "home"
680+
port_name = "http"
681+
protocol = "HTTP"
682+
timeout_sec = 10
683+
load_balancing_scheme = "EXTERNAL_MANAGED"
684+
685+
health_checks = [google_compute_health_check.default.id]
686+
}
687+
688+
resource "google_compute_backend_service" "mirror" {
689+
provider = google-beta
690+
name = "mirror"
691+
port_name = "http"
692+
protocol = "HTTP"
693+
timeout_sec = 10
694+
load_balancing_scheme = "EXTERNAL_MANAGED"
695+
696+
health_checks = [google_compute_health_check.default.id]
697+
}
698+
699+
resource "google_compute_health_check" "default" {
700+
provider = google-beta
701+
name = "health-check"
702+
http_health_check {
703+
port = 80
704+
}
705+
}
706+
```
707+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
708+
<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_path_matcher_default_mirror_percent&open_in_editor=main.tf" target="_blank">
709+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
710+
</a>
711+
</div>
712+
## Example Usage - Url Map Path Matcher Default Mirror Percent
713+
714+
715+
```hcl
716+
resource "google_compute_url_map" "urlmap" {
717+
provider = google-beta
718+
name = "urlmap"
719+
description = "Test for default route action mirror percent"
720+
721+
default_service = google_compute_backend_service.home.id
722+
723+
default_route_action {
724+
request_mirror_policy {
725+
backend_service = google_compute_backend_service.mirror.id
726+
mirror_percent = 50.0
727+
}
728+
}
729+
730+
host_rule {
731+
hosts = ["mysite.com"]
732+
path_matcher = "allpaths"
733+
}
734+
735+
path_matcher {
736+
name = "allpaths"
737+
default_service = google_compute_backend_service.home.id
738+
}
739+
}
740+
741+
resource "google_compute_backend_service" "home" {
742+
provider = google-beta
743+
name = "home"
744+
port_name = "http"
745+
protocol = "HTTP"
746+
timeout_sec = 10
747+
load_balancing_scheme = "EXTERNAL_MANAGED"
748+
749+
health_checks = [google_compute_health_check.default.id]
750+
}
751+
752+
resource "google_compute_backend_service" "mirror" {
753+
provider = google-beta
754+
name = "mirror"
755+
port_name = "http"
756+
protocol = "HTTP"
757+
timeout_sec = 10
758+
load_balancing_scheme = "EXTERNAL_MANAGED"
759+
760+
health_checks = [google_compute_health_check.default.id]
761+
}
762+
763+
resource "google_compute_health_check" "default" {
764+
provider = google-beta
765+
name = "health-check"
766+
http_health_check {
767+
port = 80
768+
}
769+
}
770+
```
771+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
772+
<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_path_rule_mirror_percent&open_in_editor=main.tf" target="_blank">
773+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
774+
</a>
775+
</div>
776+
## Example Usage - Url Map Path Rule Mirror Percent
777+
778+
779+
```hcl
780+
resource "google_compute_url_map" "urlmap" {
781+
provider = google-beta
782+
name = "urlmap"
783+
description = "Test for path matcher default route action mirror percent"
784+
785+
default_service = google_compute_backend_service.home.id
786+
787+
host_rule {
788+
hosts = ["mysite.com"]
789+
path_matcher = "allpaths"
790+
}
791+
792+
path_matcher {
793+
name = "allpaths"
794+
default_service = google_compute_backend_service.home.id
795+
796+
default_route_action {
797+
request_mirror_policy {
798+
backend_service = google_compute_backend_service.mirror.id
799+
mirror_percent = 75.0
800+
}
801+
}
802+
}
803+
}
804+
805+
resource "google_compute_backend_service" "home" {
806+
provider = google-beta
807+
name = "home"
808+
port_name = "http"
809+
protocol = "HTTP"
810+
timeout_sec = 10
811+
load_balancing_scheme = "EXTERNAL_MANAGED"
812+
813+
health_checks = [google_compute_health_check.default.id]
814+
}
815+
816+
resource "google_compute_backend_service" "mirror" {
817+
provider = google-beta
818+
name = "mirror"
819+
port_name = "http"
820+
protocol = "HTTP"
821+
timeout_sec = 10
822+
load_balancing_scheme = "EXTERNAL_MANAGED"
823+
824+
health_checks = [google_compute_health_check.default.id]
825+
}
826+
827+
resource "google_compute_health_check" "default" {
828+
provider = google-beta
829+
name = "health-check"
830+
http_health_check {
831+
port = 80
832+
}
833+
}
834+
```
835+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
836+
<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_route_rule_mirror_percent&open_in_editor=main.tf" target="_blank">
837+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
838+
</a>
839+
</div>
840+
## Example Usage - Url Map Route Rule Mirror Percent
841+
842+
843+
```hcl
844+
resource "google_compute_url_map" "urlmap" {
845+
provider = google-beta
846+
name = "urlmap"
847+
description = "Test for path rule route action mirror percent"
848+
849+
default_service = google_compute_backend_service.home.id
850+
851+
host_rule {
852+
hosts = ["mysite.com"]
853+
path_matcher = "allpaths"
854+
}
855+
856+
path_matcher {
857+
name = "allpaths"
858+
default_service = google_compute_backend_service.home.id
859+
860+
path_rule {
861+
paths = ["/home"]
862+
service = google_compute_backend_service.home.id
863+
route_action {
864+
request_mirror_policy {
865+
backend_service = google_compute_backend_service.mirror.id
866+
mirror_percent = 25.0
867+
}
868+
}
869+
}
870+
}
871+
}
872+
873+
resource "google_compute_backend_service" "home" {
874+
provider = google-beta
875+
name = "home"
876+
port_name = "http"
877+
protocol = "HTTP"
878+
timeout_sec = 10
879+
load_balancing_scheme = "EXTERNAL_MANAGED"
880+
881+
health_checks = [google_compute_health_check.default.id]
882+
}
883+
884+
resource "google_compute_backend_service" "mirror" {
885+
provider = google-beta
886+
name = "mirror"
887+
port_name = "http"
888+
protocol = "HTTP"
889+
timeout_sec = 10
890+
load_balancing_scheme = "EXTERNAL_MANAGED"
891+
892+
health_checks = [google_compute_health_check.default.id]
893+
}
894+
895+
resource "google_compute_health_check" "default" {
896+
provider = google-beta
897+
name = "health-check"
898+
http_health_check {
899+
port = 80
900+
}
901+
}
902+
```
643903
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
644904
<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_path_template_match&open_in_editor=main.tf" target="_blank">
645905
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
@@ -1401,6 +1661,11 @@ The following arguments are supported:
14011661
(Required)
14021662
The BackendService resource being mirrored to.
14031663

1664+
* `mirror_percent` -
1665+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
1666+
The percentage of requests to be mirrored to backendService.
1667+
The value must be between 0.0 and 100.0 inclusive.
1668+
14041669
<a name="nested_path_matcher_path_matcher_path_rule_path_rule_route_action_retry_policy"></a>The `retry_policy` block supports:
14051670

14061671
* `num_retries` -
@@ -2107,6 +2372,11 @@ The following arguments are supported:
21072372
(Required)
21082373
The BackendService resource being mirrored to.
21092374

2375+
* `mirror_percent` -
2376+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
2377+
The percentage of requests to be mirrored to backendService.
2378+
The value must be between 0.0 and 100.0 inclusive.
2379+
21102380
<a name="nested_path_matcher_path_matcher_route_rules_route_rules_route_action_retry_policy"></a>The `retry_policy` block supports:
21112381

21122382
* `num_retries` -
@@ -2652,6 +2922,11 @@ The following arguments are supported:
26522922
(Required)
26532923
The full or partial URL to the BackendService resource being mirrored to.
26542924

2925+
* `mirror_percent` -
2926+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
2927+
The percentage of requests to be mirrored to backendService.
2928+
The value must be between 0.0 and 100.0 inclusive.
2929+
26552930
<a name="nested_path_matcher_path_matcher_default_route_action_cors_policy"></a>The `cors_policy` block supports:
26562931

26572932
* `allow_origins` -
@@ -3078,6 +3353,11 @@ The following arguments are supported:
30783353
(Required)
30793354
The full or partial URL to the BackendService resource being mirrored to.
30803355

3356+
* `mirror_percent` -
3357+
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
3358+
The percentage of requests to be mirrored to backendService.
3359+
The value must be between 0.0 and 100.0 inclusive.
3360+
30813361
<a name="nested_default_route_action_cors_policy"></a>The `cors_policy` block supports:
30823362

30833363
* `allow_origins` -

0 commit comments

Comments
 (0)