|
| 1 | +/** |
| 2 | +* Copyright 2025 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 | +# [START networksecurity_mirroring_basic_producer] |
| 18 | +resource "google_compute_network" "default" { |
| 19 | + provider = google-beta |
| 20 | + name = "producer-network" |
| 21 | + auto_create_subnetworks = false |
| 22 | +} |
| 23 | + |
| 24 | +resource "google_compute_subnetwork" "default" { |
| 25 | + provider = google-beta |
| 26 | + name = "producer-subnet" |
| 27 | + region = "us-central1" |
| 28 | + ip_cidr_range = "10.1.0.0/16" |
| 29 | + network = google_compute_network.default.name |
| 30 | +} |
| 31 | + |
| 32 | +resource "google_compute_region_health_check" "default" { |
| 33 | + provider = google-beta |
| 34 | + name = "deploymnet-hc" |
| 35 | + region = "us-central1" |
| 36 | + http_health_check { |
| 37 | + port = 80 |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +resource "google_compute_region_backend_service" "default" { |
| 42 | + provider = google-beta |
| 43 | + name = "deployment-svc" |
| 44 | + region = "us-central1" |
| 45 | + health_checks = [google_compute_region_health_check.default.id] |
| 46 | + protocol = "UDP" |
| 47 | + load_balancing_scheme = "INTERNAL" |
| 48 | +} |
| 49 | + |
| 50 | +resource "google_compute_forwarding_rule" "default" { |
| 51 | + provider = google-beta |
| 52 | + name = "deployment-fr" |
| 53 | + region = "us-central1" |
| 54 | + network = google_compute_network.default.name |
| 55 | + subnetwork = google_compute_subnetwork.default.name |
| 56 | + backend_service = google_compute_region_backend_service.default.id |
| 57 | + load_balancing_scheme = "INTERNAL" |
| 58 | + ports = [6081] |
| 59 | + ip_protocol = "UDP" |
| 60 | + is_mirroring_collector = true |
| 61 | +} |
| 62 | + |
| 63 | +resource "google_network_security_mirroring_deployment_group" "default" { |
| 64 | + provider = google-beta |
| 65 | + mirroring_deployment_group_id = "mirroring-deployment-group" |
| 66 | + location = "global" |
| 67 | + network = google_compute_network.default.id |
| 68 | +} |
| 69 | + |
| 70 | +resource "google_network_security_mirroring_deployment" "default" { |
| 71 | + provider = google-beta |
| 72 | + mirroring_deployment_id = "mirroring-deployment" |
| 73 | + location = "us-central1-a" |
| 74 | + forwarding_rule = google_compute_forwarding_rule.default.id |
| 75 | + mirroring_deployment_group = google_network_security_mirroring_deployment_group.default.id |
| 76 | +} |
| 77 | +# [END networksecurity_mirroring_basic_producer] |
0 commit comments