Skip to content

Commit 9e9c7a9

Browse files
committed
feat(networksecurity): Add examples for creating consumer and producer intercept
1 parent 9c92e68 commit 9e9c7a9

File tree

2 files changed

+151
-0
lines changed

2 files changed

+151
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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_intercept_basic_consumer]
18+
# [START networksecurity_intercept_create_producer_network_tf]
19+
resource "google_compute_network" "producer_network" {
20+
provider = google-beta
21+
name = "producer-network"
22+
auto_create_subnetworks = false
23+
}
24+
# [END networksecurity_intercept_create_producer_network_tf]
25+
26+
# [START networksecurity_intercept_create_consumer_network_tf]
27+
resource "google_compute_network" "consumer_network" {
28+
provider = google-beta
29+
name = "consumer-network"
30+
auto_create_subnetworks = false
31+
}
32+
# [END networksecurity_intercept_create_consumer_network_tf]
33+
34+
# [START networksecurity_intercept_create_producer_deployment_group_tf]
35+
resource "google_network_security_intercept_deployment_group" "default" {
36+
provider = google-beta
37+
intercept_deployment_group_id = "intercept-deployment-group"
38+
location = "global"
39+
network = google_compute_network.producer_network.id
40+
}
41+
# [END networksecurity_intercept_create_producer_deployment_group_tf]
42+
43+
# [START networksecurity_intercept_create_endpoint_group_tf]
44+
resource "google_network_security_intercept_endpoint_group" "default" {
45+
provider = google-beta
46+
intercept_endpoint_group_id = "intercept-endpoint-group"
47+
location = "global"
48+
intercept_deployment_group = google_network_security_intercept_deployment_group.default.id
49+
}
50+
# [END networksecurity_intercept_create_endpoint_group_tf]
51+
52+
# [START networksecurity_intercept_create_endpoint_group_association_tf]
53+
resource "google_network_security_intercept_endpoint_group_association" "default" {
54+
provider = google-beta
55+
intercept_endpoint_group_association_id = "intercept-endpoint-group-association"
56+
location = "global"
57+
network = google_compute_network.consumer_network.id
58+
intercept_endpoint_group = google_network_security_intercept_endpoint_group.default.id
59+
}
60+
# [END networksecurity_intercept_create_endpoint_group_association_tf]
61+
# [END networksecurity_intercept_basic_consumer]
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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_intercept_basic_producer]
18+
# [START networksecurity_intercept_create_network_tf]
19+
resource "google_compute_network" "default" {
20+
provider = google-beta
21+
name = "producer-network"
22+
auto_create_subnetworks = false
23+
}
24+
# [END networksecurity_intercept_create_network_tf]
25+
26+
# [START networksecurity_intercept_create_subnetwork_tf]
27+
resource "google_compute_subnetwork" "default" {
28+
provider = google-beta
29+
name = "producer-subnet"
30+
region = "us-central1"
31+
ip_cidr_range = "10.1.0.0/16"
32+
network = google_compute_network.default.name
33+
}
34+
# [END networksecurity_intercept_create_subnetwork_tf]
35+
36+
# [START networksecurity_intercept_create_health_check_tf]
37+
resource "google_compute_region_health_check" "default" {
38+
provider = google-beta
39+
name = "deploymnet-hc"
40+
region = "us-central1"
41+
http_health_check {
42+
port = 80
43+
}
44+
}
45+
# [END networksecurity_intercept_create_health_check_tf]
46+
47+
# [START networksecurity_intercept_create_backend_service_tf]
48+
resource "google_compute_region_backend_service" "default" {
49+
provider = google-beta
50+
name = "deployment-svc"
51+
region = "us-central1"
52+
health_checks = [google_compute_region_health_check.default.id]
53+
protocol = "UDP"
54+
load_balancing_scheme = "INTERNAL"
55+
}
56+
# [END networksecurity_intercept_create_backend_service_tf]
57+
58+
# [START networksecurity_intercept_create_forwarding_rule_tf]
59+
resource "google_compute_forwarding_rule" "default" {
60+
provider = google-beta
61+
name = "deployment-fr"
62+
region = "us-central1"
63+
network = google_compute_network.default.name
64+
subnetwork = google_compute_subnetwork.default.name
65+
backend_service = google_compute_region_backend_service.default.id
66+
load_balancing_scheme = "INTERNAL"
67+
ports = [6081]
68+
ip_protocol = "UDP"
69+
}
70+
# [END networksecurity_intercept_create_forwarding_rule_tf]
71+
72+
# [START networksecurity_intercept_create_deployment_group_tf]
73+
resource "google_network_security_intercept_deployment_group" "default" {
74+
provider = google-beta
75+
intercept_deployment_group_id = "intercept-deployment-group"
76+
location = "global"
77+
network = google_compute_network.default.id
78+
}
79+
# [END networksecurity_intercept_create_deployment_group_tf]
80+
81+
# [START networksecurity_intercept_create_deployment_tf]
82+
resource "google_network_security_intercept_deployment" "default" {
83+
provider = google-beta
84+
intercept_deployment_id = "intercept-deployment"
85+
location = "us-central1-a"
86+
forwarding_rule = google_compute_forwarding_rule.default.id
87+
intercept_deployment_group = google_network_security_intercept_deployment_group.default.id
88+
}
89+
# [END networksecurity_intercept_create_deployment_tf]
90+
# [END networksecurity_intercept_basic_producer]

0 commit comments

Comments
 (0)