@@ -31,6 +31,16 @@ resource "google_compute_network" "consumer_network" {
3131}
3232# [END networksecurity_intercept_create_consumer_network_tf]
3333
34+ # [START networksecurity_intercept_create_consumer_subnetwork_tf]
35+ resource "google_compute_subnetwork" "consumer_subnet" {
36+ provider = google- beta
37+ name = " consumer-subnet"
38+ region = " us-central1"
39+ ip_cidr_range = " 10.10.0.0/16"
40+ network = google_compute_network. consumer_network . name
41+ }
42+ # [END networksecurity_intercept_create_consumer_subnetwork_tf]
43+
3444# [START networksecurity_intercept_create_producer_deployment_group_tf]
3545resource "google_network_security_intercept_deployment_group" "default" {
3646 provider = google- beta
@@ -58,4 +68,68 @@ resource "google_network_security_intercept_endpoint_group_association" "default
5868 intercept_endpoint_group = google_network_security_intercept_endpoint_group. default . id
5969}
6070# [END networksecurity_intercept_create_endpoint_group_association_tf]
71+
72+ data "google_project" "default" {}
73+
74+ data "google_organization" "default" {
75+ organization = data. google_project . default . org_id
76+ }
77+
78+ # [START networksecurity_intercept_create_security_profile_tf]
79+ resource "google_network_security_security_profile" "default" {
80+ provider = google- beta
81+ name = " security-profile"
82+ type = " CUSTOM_INTERCEPT"
83+ parent = " organizations/${ data . google_organization . default . org_id } "
84+ location = " global"
85+
86+ custom_intercept_profile {
87+ intercept_endpoint_group = google_network_security_intercept_endpoint_group. default . id
88+ }
89+ }
90+ # [END networksecurity_intercept_create_security_profile_tf]
91+
92+ # [START networksecurity_intercept_create_security_profile_group_tf]
93+ resource "google_network_security_security_profile_group" "default" {
94+ provider = google- beta
95+ name = " security-profile-group"
96+ parent = " organizations/${ data . google_organization . default . org_id } "
97+ location = " global"
98+ custom_intercept_profile = google_network_security_security_profile. default . id
99+ }
100+ # [END networksecurity_intercept_create_security_profile_group_tf]
101+
102+ # [START networksecurity_intercept_create_firewall_policy_tf]
103+ resource "google_compute_network_firewall_policy" "default" {
104+ provider = google- beta
105+ name = " firewall-policy"
106+ }
107+ # [END networksecurity_intercept_create_firewall_policy_tf]
108+
109+ # [START networksecurity_intercept_create_firewall_policy_rule_tf]
110+ resource "google_compute_network_firewall_policy_rule" "default" {
111+ provider = google- beta
112+ firewall_policy = google_compute_network_firewall_policy. default . name
113+ priority = 1000
114+ action = " apply_security_profile_group"
115+ direction = " INGRESS"
116+ security_profile_group = " //networksecurity.googleapis.com/${ google_network_security_security_profile_group . default . id } "
117+
118+ match {
119+ layer4_configs {
120+ ip_protocol = " tcp"
121+ ports = [" 80" ]
122+ }
123+ src_ip_ranges = [" 10.10.0.0/16" ]
124+ }
125+ }
126+ # [END networksecurity_intercept_create_firewall_policy_rule_tf]
127+
128+ # [START networksecurity_intercept_create_firewall_policy_association_tf]
129+ resource "google_compute_network_firewall_policy_association" "default" {
130+ name = " firewall-policy-assoc"
131+ attachment_target = google_compute_network. consumer_network . id
132+ firewall_policy = google_compute_network_firewall_policy. default . name
133+ }
134+ # [END networksecurity_intercept_create_firewall_policy_association_tf]
61135# [END networksecurity_intercept_basic_consumer]
0 commit comments