...
1/**
2 * Copyright 2022 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17```hcl
18resource "google_compute_network" "default" {
19 name = "compute-network"
20 auto_create_subnetworks = false
21}
22
23resource "google_compute_subnetwork" "default" {
24 name = "compute-subnet"
25 ip_cidr_range = "10.0.1.0/24"
26 region = "us-central1"
27 network = google_compute_network.default.id
28}
29
30resource "google_compute_health_check" "hc" {
31 name = "proxy-health-check"
32 check_interval_sec = 1
33 timeout_sec = 1
34
35 tcp_health_check {
36 port = "80"
37 }
38}
39
40resource "google_compute_region_backend_service" "backend" {
41 name = "compute-backend"
42 region = "us-central1"
43 health_checks = [google_compute_health_check.hc.id]
44}
45
46resource "google_compute_forwarding_rule" "default" {
47 name = "compute-forwarding-rule"
48 region = "us-central1"
49
50 load_balancing_scheme = "INTERNAL"
51 backend_service = google_compute_region_backend_service.backend.id
52 all_ports = true
53 network = google_compute_network.default.name
54 subnetwork = google_compute_subnetwork.default.name
55}
56
57resource "google_compute_route" "route-ilb" {
58 name = "route-ilb"
59 dest_range = "0.0.0.0/0"
60 network = google_compute_network.default.name
61 next_hop_ilb = google_compute_forwarding_rule.default.id
62 priority = 2000
63}
64```
View as plain text