|
| 1 | +resource "google_compute_service_attachment" "psc_ilb_service_attachment" { |
| 2 | + name = "sa-${local.name_suffix}" |
| 3 | + region = "us-central1" |
| 4 | + description = "A service attachment configured with Terraform" |
| 5 | + connection_preference = "ACCEPT_AUTOMATIC" |
| 6 | + enable_proxy_protocol = false |
| 7 | + nat_subnets = [google_compute_subnetwork.subnetwork_psc.id] |
| 8 | + target_service = google_compute_global_forwarding_rule.forwarding_rule.id |
| 9 | +} |
| 10 | + |
| 11 | +resource "google_compute_global_forwarding_rule" "forwarding_rule" { |
| 12 | + name = "sa-${local.name_suffix}" |
| 13 | + target = google_compute_target_http_proxy.http_proxy.id |
| 14 | + network = google_compute_network.network.id |
| 15 | + subnetwork = google_compute_subnetwork.subnetwork.id |
| 16 | + port_range = "80" |
| 17 | + load_balancing_scheme = "INTERNAL_MANAGED" |
| 18 | + |
| 19 | + depends_on = [google_compute_subnetwork.subnetwork_proxy] |
| 20 | +} |
| 21 | + |
| 22 | +resource "google_compute_target_http_proxy" "http_proxy" { |
| 23 | + name = "sa-${local.name_suffix}" |
| 24 | + description = "a description" |
| 25 | + url_map = google_compute_url_map.url_map.id |
| 26 | +} |
| 27 | + |
| 28 | +resource "google_compute_url_map" "url_map" { |
| 29 | + name = "sa-${local.name_suffix}" |
| 30 | + description = "Url map." |
| 31 | + default_service = google_compute_backend_service.backend_service.id |
| 32 | +} |
| 33 | + |
| 34 | +resource "google_compute_backend_service" "backend_service" { |
| 35 | + name = "sa-${local.name_suffix}" |
| 36 | + load_balancing_scheme = "INTERNAL_MANAGED" |
| 37 | + health_checks = [google_compute_health_check.health_check.id] |
| 38 | +} |
| 39 | + |
| 40 | +resource "google_compute_health_check" "health_check" { |
| 41 | + name = "sa-${local.name_suffix}" |
| 42 | + check_interval_sec = 1 |
| 43 | + timeout_sec = 1 |
| 44 | + |
| 45 | + tcp_health_check { |
| 46 | + port = "80" |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +resource "google_compute_subnetwork" "subnetwork_psc" { |
| 51 | + name = "sa-${local.name_suffix}-psc" |
| 52 | + region = "us-central1" |
| 53 | + network = google_compute_network.network.id |
| 54 | + purpose = "PRIVATE_SERVICE_CONNECT" |
| 55 | + ip_cidr_range = "10.1.0.0/16" |
| 56 | +} |
| 57 | + |
| 58 | +resource "google_compute_subnetwork" "subnetwork_proxy" { |
| 59 | + name = "sa-${local.name_suffix}-proxy" |
| 60 | + region = "us-central1" |
| 61 | + network = google_compute_network.network.id |
| 62 | + purpose = "GLOBAL_MANAGED_PROXY" |
| 63 | + role = "ACTIVE" |
| 64 | + ip_cidr_range = "10.2.0.0/16" |
| 65 | +} |
| 66 | + |
| 67 | +resource "google_compute_subnetwork" "subnetwork" { |
| 68 | + name = "sa-${local.name_suffix}" |
| 69 | + region = "us-central1" |
| 70 | + network = google_compute_network.network.id |
| 71 | + ip_cidr_range = "10.0.0.0/16" |
| 72 | +} |
| 73 | + |
| 74 | +resource "google_compute_network" "network" { |
| 75 | + name = "sa-${local.name_suffix}" |
| 76 | + auto_create_subnetworks = false |
| 77 | +} |
0 commit comments