/
globalForwardingRule.ts
1559 lines (1551 loc) · 65.7 KB
/
globalForwardingRule.ts
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
import * as utilities from "../utilities";
/**
* Represents a GlobalForwardingRule resource. Global forwarding rules are
* used to forward traffic to the correct load balancer for HTTP load
* balancing. Global forwarding rules can only be used for HTTP load
* balancing.
*
* For more information, see
* https://cloud.google.com/compute/docs/load-balancing/http/
*
* ## Example Usage
*
* ### External Tcp Proxy Lb Mig Backend
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // External TCP proxy load balancer with managed instance group backend
* // VPC
* const _default = new gcp.compute.Network("default", {
* name: "tcp-proxy-xlb-network",
* autoCreateSubnetworks: false,
* });
* // backend subnet
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "tcp-proxy-xlb-subnet",
* ipCidrRange: "10.0.1.0/24",
* region: "us-central1",
* network: _default.id,
* });
* // reserved IP address
* const defaultGlobalAddress = new gcp.compute.GlobalAddress("default", {name: "tcp-proxy-xlb-ip"});
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "tcp-proxy-health-check",
* timeoutSec: 1,
* checkIntervalSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* // instance template
* const defaultInstanceTemplate = new gcp.compute.InstanceTemplate("default", {
* networkInterfaces: [{
* accessConfigs: [{}],
* network: _default.id,
* subnetwork: defaultSubnetwork.id,
* }],
* name: "tcp-proxy-xlb-mig-template",
* machineType: "e2-small",
* tags: ["allow-health-check"],
* disks: [{
* sourceImage: "debian-cloud/debian-10",
* autoDelete: true,
* boot: true,
* }],
* metadata: {
* "startup-script": `#! /bin/bash
* set -euo pipefail
* export DEBIAN_FRONTEND=noninteractive
* apt-get update
* apt-get install -y nginx-light jq
* NAME=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname")
* IP=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip")
* METADATA=(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])')
* cat <<EOF > /var/www/html/index.html
* <pre>
* Name: NAME
* IP: IP
* Metadata: METADATA
* </pre>
* EOF
* `,
* },
* });
* // MIG
* const defaultInstanceGroupManager = new gcp.compute.InstanceGroupManager("default", {
* name: "tcp-proxy-xlb-mig1",
* zone: "us-central1-c",
* namedPorts: [{
* name: "tcp",
* port: 80,
* }],
* versions: [{
* instanceTemplate: defaultInstanceTemplate.id,
* name: "primary",
* }],
* baseInstanceName: "vm",
* targetSize: 2,
* });
* // backend service
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "tcp-proxy-xlb-backend-service",
* protocol: "TCP",
* portName: "tcp",
* loadBalancingScheme: "EXTERNAL",
* timeoutSec: 10,
* healthChecks: defaultHealthCheck.id,
* backends: [{
* group: defaultInstanceGroupManager.instanceGroup,
* balancingMode: "UTILIZATION",
* maxUtilization: 1,
* capacityScaler: 1,
* }],
* });
* const defaultTargetTCPProxy = new gcp.compute.TargetTCPProxy("default", {
* name: "test-proxy-health-check",
* backendService: defaultBackendService.id,
* });
* // forwarding rule
* const defaultGlobalForwardingRule = new gcp.compute.GlobalForwardingRule("default", {
* name: "tcp-proxy-xlb-forwarding-rule",
* ipProtocol: "TCP",
* loadBalancingScheme: "EXTERNAL",
* portRange: "110",
* target: defaultTargetTCPProxy.id,
* ipAddress: defaultGlobalAddress.id,
* });
* // allow access from health check ranges
* const defaultFirewall = new gcp.compute.Firewall("default", {
* name: "tcp-proxy-xlb-fw-allow-hc",
* direction: "INGRESS",
* network: _default.id,
* sourceRanges: [
* "130.211.0.0/22",
* "35.191.0.0/16",
* ],
* allows: [{
* protocol: "tcp",
* }],
* targetTags: ["allow-health-check"],
* });
* ```
* ### External Http Lb Mig Backend Custom Header
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // External HTTP load balancer with a CDN-enabled managed instance group backend
* // and custom request and response headers
* // VPC
* const _default = new gcp.compute.Network("default", {
* name: "l7-xlb-network",
* autoCreateSubnetworks: false,
* });
* // backend subnet
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "l7-xlb-subnet",
* ipCidrRange: "10.0.1.0/24",
* region: "us-central1",
* network: _default.id,
* });
* // reserved IP address
* const defaultGlobalAddress = new gcp.compute.GlobalAddress("default", {name: "l7-xlb-static-ip"});
* // health check
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "l7-xlb-hc",
* httpHealthCheck: {
* portSpecification: "USE_SERVING_PORT",
* },
* });
* // instance template
* const defaultInstanceTemplate = new gcp.compute.InstanceTemplate("default", {
* networkInterfaces: [{
* accessConfigs: [{}],
* network: _default.id,
* subnetwork: defaultSubnetwork.id,
* }],
* name: "l7-xlb-mig-template",
* machineType: "e2-small",
* tags: ["allow-health-check"],
* disks: [{
* sourceImage: "debian-cloud/debian-10",
* autoDelete: true,
* boot: true,
* }],
* metadata: {
* "startup-script": `#! /bin/bash
* set -euo pipefail
*
* export DEBIAN_FRONTEND=noninteractive
* apt-get update
* apt-get install -y nginx-light jq
*
* NAME=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname")
* IP=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip")
* METADATA=(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])')
*
* cat <<EOF > /var/www/html/index.html
* <pre>
* Name: NAME
* IP: IP
* Metadata: METADATA
* </pre>
* EOF
* `,
* },
* });
* // MIG
* const defaultInstanceGroupManager = new gcp.compute.InstanceGroupManager("default", {
* name: "l7-xlb-mig1",
* zone: "us-central1-c",
* namedPorts: [{
* name: "http",
* port: 8080,
* }],
* versions: [{
* instanceTemplate: defaultInstanceTemplate.id,
* name: "primary",
* }],
* baseInstanceName: "vm",
* targetSize: 2,
* });
* // backend service with custom request and response headers
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "l7-xlb-backend-service",
* protocol: "HTTP",
* portName: "my-port",
* loadBalancingScheme: "EXTERNAL",
* timeoutSec: 10,
* enableCdn: true,
* customRequestHeaders: ["X-Client-Geo-Location: {client_region_subdivision}, {client_city}"],
* customResponseHeaders: ["X-Cache-Hit: {cdn_cache_status}"],
* healthChecks: defaultHealthCheck.id,
* backends: [{
* group: defaultInstanceGroupManager.instanceGroup,
* balancingMode: "UTILIZATION",
* capacityScaler: 1,
* }],
* });
* // url map
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "l7-xlb-url-map",
* defaultService: defaultBackendService.id,
* });
* // http proxy
* const defaultTargetHttpProxy = new gcp.compute.TargetHttpProxy("default", {
* name: "l7-xlb-target-http-proxy",
* urlMap: defaultURLMap.id,
* });
* // forwarding rule
* const defaultGlobalForwardingRule = new gcp.compute.GlobalForwardingRule("default", {
* name: "l7-xlb-forwarding-rule",
* ipProtocol: "TCP",
* loadBalancingScheme: "EXTERNAL",
* portRange: "80",
* target: defaultTargetHttpProxy.id,
* ipAddress: defaultGlobalAddress.id,
* });
* // allow access from health check ranges
* const defaultFirewall = new gcp.compute.Firewall("default", {
* name: "l7-xlb-fw-allow-hc",
* direction: "INGRESS",
* network: _default.id,
* sourceRanges: [
* "130.211.0.0/22",
* "35.191.0.0/16",
* ],
* allows: [{
* protocol: "tcp",
* }],
* targetTags: ["allow-health-check"],
* });
* ```
* ### Global Forwarding Rule Http
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", {
* name: "check-backend",
* requestPath: "/",
* checkIntervalSec: 1,
* timeoutSec: 1,
* });
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* healthChecks: defaultHttpHealthCheck.id,
* });
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "url-map-target-proxy",
* description: "a description",
* defaultService: defaultBackendService.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: defaultBackendService.id,
* pathRules: [{
* paths: ["/*"],
* service: defaultBackendService.id,
* }],
* }],
* });
* const defaultTargetHttpProxy = new gcp.compute.TargetHttpProxy("default", {
* name: "target-proxy",
* description: "a description",
* urlMap: defaultURLMap.id,
* });
* const _default = new gcp.compute.GlobalForwardingRule("default", {
* name: "global-rule",
* target: defaultTargetHttpProxy.id,
* portRange: "80",
* });
* ```
* ### Global Forwarding Rule Internal
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const debianImage = gcp.compute.getImage({
* family: "debian-11",
* project: "debian-cloud",
* });
* const instanceTemplate = new gcp.compute.InstanceTemplate("instance_template", {
* name: "template-backend",
* machineType: "e2-medium",
* networkInterfaces: [{
* network: "default",
* }],
* disks: [{
* sourceImage: debianImage.then(debianImage => debianImage.selfLink),
* autoDelete: true,
* boot: true,
* }],
* });
* const igm = new gcp.compute.InstanceGroupManager("igm", {
* name: "igm-internal",
* versions: [{
* instanceTemplate: instanceTemplate.id,
* name: "primary",
* }],
* baseInstanceName: "internal-glb",
* zone: "us-central1-f",
* targetSize: 1,
* });
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "check-backend",
* checkIntervalSec: 1,
* timeoutSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* backends: [{
* group: igm.instanceGroup,
* balancingMode: "RATE",
* capacityScaler: 0.4,
* maxRatePerInstance: 50,
* }],
* healthChecks: defaultHealthCheck.id,
* });
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "url-map-target-proxy",
* description: "a description",
* defaultService: defaultBackendService.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: defaultBackendService.id,
* pathRules: [{
* paths: ["/*"],
* service: defaultBackendService.id,
* }],
* }],
* });
* const defaultTargetHttpProxy = new gcp.compute.TargetHttpProxy("default", {
* name: "target-proxy",
* description: "a description",
* urlMap: defaultURLMap.id,
* });
* const _default = new gcp.compute.GlobalForwardingRule("default", {
* name: "global-rule",
* target: defaultTargetHttpProxy.id,
* portRange: "80",
* loadBalancingScheme: "INTERNAL_SELF_MANAGED",
* ipAddress: "0.0.0.0",
* metadataFilters: [{
* filterMatchCriteria: "MATCH_ANY",
* filterLabels: [{
* name: "PLANET",
* value: "MARS",
* }],
* }],
* });
* ```
* ### Global Forwarding Rule External Managed
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "backend",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* loadBalancingScheme: "EXTERNAL_MANAGED",
* });
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "url-map-target-proxy",
* description: "a description",
* defaultService: defaultBackendService.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: defaultBackendService.id,
* pathRules: [{
* paths: ["/*"],
* service: defaultBackendService.id,
* }],
* }],
* });
* const defaultTargetHttpProxy = new gcp.compute.TargetHttpProxy("default", {
* name: "target-proxy",
* description: "a description",
* urlMap: defaultURLMap.id,
* });
* const _default = new gcp.compute.GlobalForwardingRule("default", {
* name: "global-rule",
* target: defaultTargetHttpProxy.id,
* portRange: "80",
* loadBalancingScheme: "EXTERNAL_MANAGED",
* });
* ```
* ### Global Forwarding Rule Hybrid
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const config = new pulumi.Config();
* const subnetworkCidr = config.get("subnetworkCidr") || "10.0.0.0/24";
* const _default = new gcp.compute.Network("default", {name: "my-network"});
* const internal = new gcp.compute.Network("internal", {
* name: "my-internal-network",
* autoCreateSubnetworks: false,
* });
* const internalSubnetwork = new gcp.compute.Subnetwork("internal", {
* name: "my-subnetwork",
* network: internal.id,
* ipCidrRange: subnetworkCidr,
* region: "us-central1",
* privateIpGoogleAccess: true,
* });
* // Zonal NEG with GCE_VM_IP_PORT
* const defaultNetworkEndpointGroup = new gcp.compute.NetworkEndpointGroup("default", {
* name: "default-neg",
* network: _default.id,
* defaultPort: 90,
* zone: "us-central1-a",
* networkEndpointType: "GCE_VM_IP_PORT",
* });
* // Zonal NEG with GCE_VM_IP
* const internalNetworkEndpointGroup = new gcp.compute.NetworkEndpointGroup("internal", {
* name: "internal-neg",
* network: internal.id,
* subnetwork: internalSubnetwork.id,
* zone: "us-central1-a",
* networkEndpointType: "GCE_VM_IP",
* });
* // Hybrid connectivity NEG
* const hybrid = new gcp.compute.NetworkEndpointGroup("hybrid", {
* name: "hybrid-neg",
* network: _default.id,
* defaultPort: 90,
* zone: "us-central1-a",
* networkEndpointType: "NON_GCP_PRIVATE_IP_PORT",
* });
* const hybrid_endpoint = new gcp.compute.NetworkEndpoint("hybrid-endpoint", {
* networkEndpointGroup: hybrid.name,
* port: hybrid.defaultPort,
* ipAddress: "127.0.0.1",
* });
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "health-check",
* timeoutSec: 1,
* checkIntervalSec: 1,
* tcpHealthCheck: {
* port: 80,
* },
* });
* // Backend service for Zonal NEG
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "backend-default",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* backends: [{
* group: defaultNetworkEndpointGroup.id,
* balancingMode: "RATE",
* maxRatePerEndpoint: 10,
* }],
* healthChecks: defaultHealthCheck.id,
* });
* // Backgend service for Hybrid NEG
* const hybridBackendService = new gcp.compute.BackendService("hybrid", {
* name: "backend-hybrid",
* portName: "http",
* protocol: "HTTP",
* timeoutSec: 10,
* backends: [{
* group: hybrid.id,
* balancingMode: "RATE",
* maxRatePerEndpoint: 10,
* }],
* healthChecks: defaultHealthCheck.id,
* });
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "url-map-target-proxy",
* description: "a description",
* defaultService: defaultBackendService.id,
* hostRules: [{
* hosts: ["mysite.com"],
* pathMatcher: "allpaths",
* }],
* pathMatchers: [{
* name: "allpaths",
* defaultService: defaultBackendService.id,
* pathRules: [
* {
* paths: ["/*"],
* service: defaultBackendService.id,
* },
* {
* paths: ["/hybrid"],
* service: hybridBackendService.id,
* },
* ],
* }],
* });
* const defaultTargetHttpProxy = new gcp.compute.TargetHttpProxy("default", {
* name: "target-proxy",
* description: "a description",
* urlMap: defaultURLMap.id,
* });
* const defaultGlobalForwardingRule = new gcp.compute.GlobalForwardingRule("default", {
* name: "global-rule",
* target: defaultTargetHttpProxy.id,
* portRange: "80",
* });
* ```
* ### Global Internal Http Lb With Mig Backend
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* // Global Internal HTTP load balancer with a managed instance group backend
* // VPC network
* const gilbNetwork = new gcp.compute.Network("gilb_network", {
* name: "l7-gilb-network",
* autoCreateSubnetworks: false,
* });
* // proxy-only subnet
* const proxySubnet = new gcp.compute.Subnetwork("proxy_subnet", {
* name: "l7-gilb-proxy-subnet",
* ipCidrRange: "10.0.0.0/24",
* region: "europe-west1",
* purpose: "GLOBAL_MANAGED_PROXY",
* role: "ACTIVE",
* network: gilbNetwork.id,
* });
* // backend subnet
* const gilbSubnet = new gcp.compute.Subnetwork("gilb_subnet", {
* name: "l7-gilb-subnet",
* ipCidrRange: "10.0.1.0/24",
* region: "europe-west1",
* network: gilbNetwork.id,
* });
* // health check
* const defaultHealthCheck = new gcp.compute.HealthCheck("default", {
* name: "l7-gilb-hc",
* httpHealthCheck: {
* portSpecification: "USE_SERVING_PORT",
* },
* });
* // instance template
* const instanceTemplate = new gcp.compute.InstanceTemplate("instance_template", {
* networkInterfaces: [{
* accessConfigs: [{}],
* network: gilbNetwork.id,
* subnetwork: gilbSubnet.id,
* }],
* name: "l7-gilb-mig-template",
* machineType: "e2-small",
* tags: ["http-server"],
* disks: [{
* sourceImage: "debian-cloud/debian-10",
* autoDelete: true,
* boot: true,
* }],
* metadata: {
* "startup-script": `#! /bin/bash
* set -euo pipefail
*
* export DEBIAN_FRONTEND=noninteractive
* apt-get update
* apt-get install -y nginx-light jq
*
* NAME=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/hostname")
* IP=(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip")
* METADATA=(curl -f -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=True" | jq 'del(.["startup-script"])')
*
* cat <<EOF > /var/www/html/index.html
* <pre>
* Name: NAME
* IP: IP
* Metadata: METADATA
* </pre>
* EOF
* `,
* },
* });
* // MIG
* const mig = new gcp.compute.InstanceGroupManager("mig", {
* name: "l7-gilb-mig1",
* zone: "europe-west1-b",
* versions: [{
* instanceTemplate: instanceTemplate.id,
* name: "primary",
* }],
* baseInstanceName: "vm",
* targetSize: 2,
* });
* // backend service
* const defaultBackendService = new gcp.compute.BackendService("default", {
* name: "l7-gilb-backend-subnet",
* protocol: "HTTP",
* loadBalancingScheme: "INTERNAL_MANAGED",
* timeoutSec: 10,
* healthChecks: defaultHealthCheck.id,
* backends: [{
* group: mig.instanceGroup,
* balancingMode: "UTILIZATION",
* capacityScaler: 1,
* }],
* });
* // URL map
* const defaultURLMap = new gcp.compute.URLMap("default", {
* name: "l7-gilb-url-map",
* defaultService: defaultBackendService.id,
* });
* // HTTP target proxy
* const _default = new gcp.compute.TargetHttpProxy("default", {
* name: "l7-gilb-target-http-proxy",
* urlMap: defaultURLMap.id,
* });
* // forwarding rule
* const googleComputeForwardingRule = new gcp.compute.GlobalForwardingRule("google_compute_forwarding_rule", {
* name: "l7-gilb-forwarding-rule",
* ipProtocol: "TCP",
* loadBalancingScheme: "INTERNAL_MANAGED",
* portRange: "80",
* target: _default.id,
* network: gilbNetwork.id,
* subnetwork: gilbSubnet.id,
* });
* // allow all access from IAP and health check ranges
* const fw_iap = new gcp.compute.Firewall("fw-iap", {
* name: "l7-gilb-fw-allow-iap-hc",
* direction: "INGRESS",
* network: gilbNetwork.id,
* sourceRanges: [
* "130.211.0.0/22",
* "35.191.0.0/16",
* "35.235.240.0/20",
* ],
* allows: [{
* protocol: "tcp",
* }],
* });
* // allow http from proxy subnet to backends
* const fw_gilb_to_backends = new gcp.compute.Firewall("fw-gilb-to-backends", {
* name: "l7-gilb-fw-allow-gilb-to-backends",
* direction: "INGRESS",
* network: gilbNetwork.id,
* sourceRanges: ["10.0.0.0/24"],
* targetTags: ["http-server"],
* allows: [{
* protocol: "tcp",
* ports: [
* "80",
* "443",
* "8080",
* ],
* }],
* });
* // test instance
* const vm_test = new gcp.compute.Instance("vm-test", {
* name: "l7-gilb-test-vm",
* zone: "europe-west1-b",
* machineType: "e2-small",
* networkInterfaces: [{
* network: gilbNetwork.id,
* subnetwork: gilbSubnet.id,
* }],
* bootDisk: {
* initializeParams: {
* image: "debian-cloud/debian-10",
* },
* },
* });
* ```
* ### Private Service Connect Google Apis
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const network = new gcp.compute.Network("network", {
* project: "my-project-name",
* name: "my-network",
* autoCreateSubnetworks: false,
* });
* const vpcSubnetwork = new gcp.compute.Subnetwork("vpc_subnetwork", {
* project: network.project,
* name: "my-subnetwork",
* ipCidrRange: "10.2.0.0/16",
* region: "us-central1",
* network: network.id,
* privateIpGoogleAccess: true,
* });
* const _default = new gcp.compute.GlobalAddress("default", {
* project: network.project,
* name: "global-psconnect-ip",
* addressType: "INTERNAL",
* purpose: "PRIVATE_SERVICE_CONNECT",
* network: network.id,
* address: "100.100.100.106",
* });
* const defaultGlobalForwardingRule = new gcp.compute.GlobalForwardingRule("default", {
* project: network.project,
* name: "globalrule",
* target: "all-apis",
* network: network.id,
* ipAddress: _default.id,
* loadBalancingScheme: "",
* serviceDirectoryRegistrations: {
* namespace: "sd-namespace",
* serviceDirectoryRegion: "europe-west3",
* },
* });
* ```
* ### Private Service Connect Google Apis No Automate Dns
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const network = new gcp.compute.Network("network", {
* project: "my-project-name",
* name: "my-network",
* autoCreateSubnetworks: false,
* });
* const vpcSubnetwork = new gcp.compute.Subnetwork("vpc_subnetwork", {
* project: network.project,
* name: "my-subnetwork",
* ipCidrRange: "10.2.0.0/16",
* region: "us-central1",
* network: network.id,
* privateIpGoogleAccess: true,
* });
* const _default = new gcp.compute.GlobalAddress("default", {
* project: network.project,
* name: "global-psconnect-ip",
* addressType: "INTERNAL",
* purpose: "PRIVATE_SERVICE_CONNECT",
* network: network.id,
* address: "100.100.100.106",
* });
* const defaultGlobalForwardingRule = new gcp.compute.GlobalForwardingRule("default", {
* project: network.project,
* name: "globalrule",
* target: "all-apis",
* network: network.id,
* ipAddress: _default.id,
* loadBalancingScheme: "",
* noAutomateDnsZone: false,
* });
* ```
*
* ## Import
*
* GlobalForwardingRule can be imported using any of these accepted formats:
*
* * `projects/{{project}}/global/forwardingRules/{{name}}`
*
* * `{{project}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, GlobalForwardingRule can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/globalForwardingRule:GlobalForwardingRule default projects/{{project}}/global/forwardingRules/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/globalForwardingRule:GlobalForwardingRule default {{project}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/globalForwardingRule:GlobalForwardingRule default {{name}}
* ```
*/
export class GlobalForwardingRule extends pulumi.CustomResource {
/**
* Get an existing GlobalForwardingRule resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: GlobalForwardingRuleState, opts?: pulumi.CustomResourceOptions): GlobalForwardingRule {
return new GlobalForwardingRule(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'gcp:compute/globalForwardingRule:GlobalForwardingRule';
/**
* Returns true if the given object is an instance of GlobalForwardingRule. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is GlobalForwardingRule {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === GlobalForwardingRule.__pulumiType;
}
/**
* This is used in PSC consumer ForwardingRule to control whether the PSC endpoint can be accessed from another region.
*/
public readonly allowPscGlobalAccess!: pulumi.Output<boolean | undefined>;
/**
* [Output Only] The URL for the corresponding base Forwarding Rule. By base Forwarding Rule, we mean the Forwarding Rule that has the same IP address, protocol, and port settings with the current Forwarding Rule, but without sourceIPRanges specified. Always empty if the current Forwarding Rule does not have sourceIPRanges specified.
*/
public /*out*/ readonly baseForwardingRule!: pulumi.Output<string>;
/**
* An optional description of this resource. Provide this property when
* you create the resource.
*/
public readonly description!: pulumi.Output<string | undefined>;
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
*/
public /*out*/ readonly effectiveLabels!: pulumi.Output<{[key: string]: string}>;
/**
* IP address for which this forwarding rule accepts traffic. When a client
* sends traffic to this IP address, the forwarding rule directs the traffic
* to the referenced `target`.
* While creating a forwarding rule, specifying an `IPAddress` is
* required under the following circumstances:
* * When the `target` is set to `targetGrpcProxy` and
* `validateForProxyless` is set to `true`, the
* `IPAddress` should be set to `0.0.0.0`.
* * When the `target` is a Private Service Connect Google APIs
* bundle, you must specify an `IPAddress`.
*
* Otherwise, you can optionally specify an IP address that references an
* existing static (reserved) IP address resource. When omitted, Google Cloud
* assigns an ephemeral IP address.
* Use one of the following formats to specify an IP address while creating a
* forwarding rule:
* * IP address number, as in `100.1.2.3`
* * IPv6 address range, as in `2600:1234::/96`
* * Full resource URL, as in
* `https://www.googleapis.com/compute/v1/projects/project_id/regions/region/addresses/address-name`
* * Partial URL or by name, as in:
* * `projects/project_id/regions/region/addresses/address-name`
* * `regions/region/addresses/address-name`
* * `global/addresses/address-name`
* * `address-name`
*
* The forwarding rule's `target`,
* and in most cases, also the `loadBalancingScheme`, determine the
* type of IP address that you can use. For detailed information, see
* [IP address
* specifications](https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts#ip_address_specifications).
* When reading an `IPAddress`, the API always returns the IP
* address number.
*/
public readonly ipAddress!: pulumi.Output<string>;
/**
* The IP protocol to which this rule applies.
* For protocol forwarding, valid
* options are `TCP`, `UDP`, `ESP`,
* `AH`, `SCTP`, `ICMP` and
* `L3_DEFAULT`.
* The valid IP protocols are different for different load balancing products
* as described in [Load balancing
* features](https://cloud.google.com/load-balancing/docs/features#protocols_from_the_load_balancer_to_the_backends).
* Possible values are: `TCP`, `UDP`, `ESP`, `AH`, `SCTP`, `ICMP`.
*/
public readonly ipProtocol!: pulumi.Output<string>;
/**
* The IP Version that will be used by this global forwarding rule.
* Possible values are: `IPV4`, `IPV6`.
*/
public readonly ipVersion!: pulumi.Output<string | undefined>;
/**
* The fingerprint used for optimistic locking of this resource. Used
* internally during updates.
*/
public /*out*/ readonly labelFingerprint!: pulumi.Output<string>;
/**
* Labels to apply to this forwarding rule. A list of key->value pairs.
*
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field `effectiveLabels` for all of the labels present on the resource.
*/
public readonly labels!: pulumi.Output<{[key: string]: string} | undefined>;
/**
* Specifies the forwarding rule type.
* For more information about forwarding rules, refer to
* [Forwarding rule concepts](https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts).
* Default value is `EXTERNAL`.
* Possible values are: `EXTERNAL`, `EXTERNAL_MANAGED`, `INTERNAL_MANAGED`, `INTERNAL_SELF_MANAGED`.
*/
public readonly loadBalancingScheme!: pulumi.Output<string | undefined>;
/**
* Opaque filter criteria used by Loadbalancer to restrict routing
* configuration to a limited set xDS compliant clients. In their xDS
* requests to Loadbalancer, xDS clients present node metadata. If a
* match takes place, the relevant routing configuration is made available
* to those proxies.
* For each metadataFilter in this list, if its filterMatchCriteria is set
* to MATCH_ANY, at least one of the filterLabels must match the
* corresponding label provided in the metadata. If its filterMatchCriteria
* is set to MATCH_ALL, then all of its filterLabels must match with
* corresponding labels in the provided metadata.
* metadataFilters specified here can be overridden by those specified in
* the UrlMap that this ForwardingRule references.
* metadataFilters only applies to Loadbalancers that have their
* loadBalancingScheme set to INTERNAL_SELF_MANAGED.
* Structure is documented below.
*/
public readonly metadataFilters!: pulumi.Output<outputs.compute.GlobalForwardingRuleMetadataFilter[] | undefined>;
/**
* Name of the resource; provided by the client when the resource is created.
* The name must be 1-63 characters long, and comply with
* [RFC1035](https://www.ietf.org/rfc/rfc1035.txt).
* Specifically, the name must be 1-63 characters long and match the regular
* expression `a-z?` which means the first
* character must be a lowercase letter, and all following characters must
* be a dash, lowercase letter, or digit, except the last character, which
* cannot be a dash.
* For Private Service Connect forwarding rules that forward traffic to Google
* APIs, the forwarding rule name must be a 1-20 characters string with
* lowercase letters and numbers and must start with a letter.
*/
public readonly name!: pulumi.Output<string>;
/**
* This field is not used for external load balancing.
* For Internal TCP/UDP Load Balancing, this field identifies the network that
* the load balanced IP should belong to for this Forwarding Rule.
* If the subnetwork is specified, the network of the subnetwork will be used.
* If neither subnetwork nor this field is specified, the default network will
* be used.
* For Private Service Connect forwarding rules that forward traffic to Google
* APIs, a network must be provided.
*/
public readonly network!: pulumi.Output<string>;
/**
* This is used in PSC consumer ForwardingRule to control whether it should try to auto-generate a DNS zone or not. Non-PSC forwarding rules do not use this field.
*/
public readonly noAutomateDnsZone!: pulumi.Output<boolean | undefined>;
/**
* The `portRange` field has the following limitations: