1414* limitations under the License.
1515*/
1616
17+ data "google_project" "default" {
18+ provider = google- beta
19+ }
20+
21+ # In case the project is in a folder, extract the organization ID from it.
22+ data "google_folder" "default" {
23+ provider = google- beta
24+ count = data. google_project . default . folder_id != " " ? 1 : 0
25+ folder = data. google_project . default . folder_id
26+ lookup_organization = true
27+ }
28+
29+ data "google_organization" "default" {
30+ provider = google- beta
31+ organization = data. google_project . default . org_id != " " ? data. google_project . default . org_id : data. google_folder . default [0 ]. organization
32+ }
33+
1734# [START networksecurity_intercept_basic_consumer]
1835# [START networksecurity_intercept_create_producer_network_tf]
1936resource "google_compute_network" "producer_network" {
@@ -31,6 +48,16 @@ resource "google_compute_network" "consumer_network" {
3148}
3249# [END networksecurity_intercept_create_consumer_network_tf]
3350
51+ # [START networksecurity_intercept_create_consumer_subnetwork_tf]
52+ resource "google_compute_subnetwork" "consumer_subnet" {
53+ provider = google- beta
54+ name = " consumer-subnet"
55+ region = " us-central1"
56+ ip_cidr_range = " 10.10.0.0/16"
57+ network = google_compute_network. consumer_network . name
58+ }
59+ # [END networksecurity_intercept_create_consumer_subnetwork_tf]
60+
3461# [START networksecurity_intercept_create_producer_deployment_group_tf]
3562resource "google_network_security_intercept_deployment_group" "default" {
3663 provider = google- beta
@@ -58,4 +85,63 @@ resource "google_network_security_intercept_endpoint_group_association" "default
5885 intercept_endpoint_group = google_network_security_intercept_endpoint_group. default . id
5986}
6087# [END networksecurity_intercept_create_endpoint_group_association_tf]
88+
89+ # [START networksecurity_intercept_create_security_profile_tf]
90+ resource "google_network_security_security_profile" "default" {
91+ provider = google- beta
92+ name = " security-profile"
93+ type = " CUSTOM_INTERCEPT"
94+ parent = " organizations/${ data . google_organization . default . org_id } "
95+ location = " global"
96+
97+ custom_intercept_profile {
98+ intercept_endpoint_group = google_network_security_intercept_endpoint_group. default . id
99+ }
100+ }
101+ # [END networksecurity_intercept_create_security_profile_tf]
102+
103+ # [START networksecurity_intercept_create_security_profile_group_tf]
104+ resource "google_network_security_security_profile_group" "default" {
105+ provider = google- beta
106+ name = " security-profile-group"
107+ parent = " organizations/${ data . google_organization . default . org_id } "
108+ location = " global"
109+ custom_intercept_profile = google_network_security_security_profile. default . id
110+ }
111+ # [END networksecurity_intercept_create_security_profile_group_tf]
112+
113+ # [START networksecurity_intercept_create_firewall_policy_tf]
114+ resource "google_compute_network_firewall_policy" "default" {
115+ provider = google- beta
116+ name = " firewall-policy"
117+ }
118+ # [END networksecurity_intercept_create_firewall_policy_tf]
119+
120+ # [START networksecurity_intercept_create_firewall_policy_rule_tf]
121+ resource "google_compute_network_firewall_policy_rule" "default" {
122+ provider = google- beta
123+ firewall_policy = google_compute_network_firewall_policy. default . name
124+ priority = 1000
125+ action = " apply_security_profile_group"
126+ direction = " INGRESS"
127+ security_profile_group = google_network_security_security_profile_group. default . id
128+
129+ match {
130+ layer4_configs {
131+ ip_protocol = " tcp"
132+ ports = [" 80" ]
133+ }
134+ src_ip_ranges = [" 10.10.0.0/16" ]
135+ }
136+ }
137+ # [END networksecurity_intercept_create_firewall_policy_rule_tf]
138+
139+ # [START networksecurity_intercept_create_firewall_policy_association_tf]
140+ resource "google_compute_network_firewall_policy_association" "default" {
141+ provider = google- beta
142+ name = " firewall-policy-assoc"
143+ attachment_target = google_compute_network. consumer_network . id
144+ firewall_policy = google_compute_network_firewall_policy. default . name
145+ }
146+ # [END networksecurity_intercept_create_firewall_policy_association_tf]
61147# [END networksecurity_intercept_basic_consumer]
0 commit comments