@@ -65,8 +65,44 @@ func ResourceNetworkSecuritySecurityProfile() *schema.Resource {
65
65
Type : schema .TypeString ,
66
66
Required : true ,
67
67
ForceNew : true ,
68
- ValidateFunc : verify .ValidateEnum ([]string {"THREAT_PREVENTION" }),
69
- Description : `The type of security profile. Possible values: ["THREAT_PREVENTION"]` ,
68
+ ValidateFunc : verify .ValidateEnum ([]string {"THREAT_PREVENTION" , "CUSTOM_MIRRORING" , "CUSTOM_INTERCEPT" }),
69
+ Description : `The type of security profile. Possible values: ["THREAT_PREVENTION", "CUSTOM_MIRRORING", "CUSTOM_INTERCEPT"]` ,
70
+ },
71
+ "custom_intercept_profile" : {
72
+ Type : schema .TypeList ,
73
+ Optional : true ,
74
+ Description : `The configuration for defining the Intercept Endpoint Group used to
75
+ intercept traffic to third-party firewall appliances.` ,
76
+ MaxItems : 1 ,
77
+ Elem : & schema.Resource {
78
+ Schema : map [string ]* schema.Schema {
79
+ "intercept_endpoint_group" : {
80
+ Type : schema .TypeString ,
81
+ Required : true ,
82
+ Description : `The Intercept Endpoint Group to which matching traffic should be intercepted.
83
+ Format: projects/{project_id}/locations/global/interceptEndpointGroups/{endpoint_group_id}` ,
84
+ },
85
+ },
86
+ },
87
+ ConflictsWith : []string {"threat_prevention_profile" , "custom_mirroring_profile" },
88
+ },
89
+ "custom_mirroring_profile" : {
90
+ Type : schema .TypeList ,
91
+ Optional : true ,
92
+ Description : `The configuration for defining the Mirroring Endpoint Group used to
93
+ mirror traffic to third-party collectors.` ,
94
+ MaxItems : 1 ,
95
+ Elem : & schema.Resource {
96
+ Schema : map [string ]* schema.Schema {
97
+ "mirroring_endpoint_group" : {
98
+ Type : schema .TypeString ,
99
+ Required : true ,
100
+ Description : `The Mirroring Endpoint Group to which matching traffic should be mirrored.
101
+ Format: projects/{project_id}/locations/global/mirroringEndpointGroups/{endpoint_group_id}` ,
102
+ },
103
+ },
104
+ },
105
+ ConflictsWith : []string {"threat_prevention_profile" , "custom_intercept_profile" },
70
106
},
71
107
"description" : {
72
108
Type : schema .TypeString ,
@@ -155,6 +191,7 @@ and threat overrides, the threat overrides action is applied.`,
155
191
},
156
192
},
157
193
},
194
+ ConflictsWith : []string {"custom_mirroring_profile" , "custom_intercept_profile" },
158
195
},
159
196
"create_time" : {
160
197
Type : schema .TypeString ,
@@ -217,6 +254,18 @@ func resourceNetworkSecuritySecurityProfileCreate(d *schema.ResourceData, meta i
217
254
} else if v , ok := d .GetOkExists ("threat_prevention_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (threatPreventionProfileProp )) && (ok || ! reflect .DeepEqual (v , threatPreventionProfileProp )) {
218
255
obj ["threatPreventionProfile" ] = threatPreventionProfileProp
219
256
}
257
+ customMirroringProfileProp , err := expandNetworkSecuritySecurityProfileCustomMirroringProfile (d .Get ("custom_mirroring_profile" ), d , config )
258
+ if err != nil {
259
+ return err
260
+ } else if v , ok := d .GetOkExists ("custom_mirroring_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (customMirroringProfileProp )) && (ok || ! reflect .DeepEqual (v , customMirroringProfileProp )) {
261
+ obj ["customMirroringProfile" ] = customMirroringProfileProp
262
+ }
263
+ customInterceptProfileProp , err := expandNetworkSecuritySecurityProfileCustomInterceptProfile (d .Get ("custom_intercept_profile" ), d , config )
264
+ if err != nil {
265
+ return err
266
+ } else if v , ok := d .GetOkExists ("custom_intercept_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (customInterceptProfileProp )) && (ok || ! reflect .DeepEqual (v , customInterceptProfileProp )) {
267
+ obj ["customInterceptProfile" ] = customInterceptProfileProp
268
+ }
220
269
typeProp , err := expandNetworkSecuritySecurityProfileType (d .Get ("type" ), d , config )
221
270
if err != nil {
222
271
return err
@@ -333,6 +382,12 @@ func resourceNetworkSecuritySecurityProfileRead(d *schema.ResourceData, meta int
333
382
if err := d .Set ("threat_prevention_profile" , flattenNetworkSecuritySecurityProfileThreatPreventionProfile (res ["threatPreventionProfile" ], d , config )); err != nil {
334
383
return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
335
384
}
385
+ if err := d .Set ("custom_mirroring_profile" , flattenNetworkSecuritySecurityProfileCustomMirroringProfile (res ["customMirroringProfile" ], d , config )); err != nil {
386
+ return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
387
+ }
388
+ if err := d .Set ("custom_intercept_profile" , flattenNetworkSecuritySecurityProfileCustomInterceptProfile (res ["customInterceptProfile" ], d , config )); err != nil {
389
+ return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
390
+ }
336
391
if err := d .Set ("type" , flattenNetworkSecuritySecurityProfileType (res ["type" ], d , config )); err != nil {
337
392
return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
338
393
}
@@ -369,6 +424,18 @@ func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta i
369
424
} else if v , ok := d .GetOkExists ("threat_prevention_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , threatPreventionProfileProp )) {
370
425
obj ["threatPreventionProfile" ] = threatPreventionProfileProp
371
426
}
427
+ customMirroringProfileProp , err := expandNetworkSecuritySecurityProfileCustomMirroringProfile (d .Get ("custom_mirroring_profile" ), d , config )
428
+ if err != nil {
429
+ return err
430
+ } else if v , ok := d .GetOkExists ("custom_mirroring_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , customMirroringProfileProp )) {
431
+ obj ["customMirroringProfile" ] = customMirroringProfileProp
432
+ }
433
+ customInterceptProfileProp , err := expandNetworkSecuritySecurityProfileCustomInterceptProfile (d .Get ("custom_intercept_profile" ), d , config )
434
+ if err != nil {
435
+ return err
436
+ } else if v , ok := d .GetOkExists ("custom_intercept_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , customInterceptProfileProp )) {
437
+ obj ["customInterceptProfile" ] = customInterceptProfileProp
438
+ }
372
439
labelsProp , err := expandNetworkSecuritySecurityProfileEffectiveLabels (d .Get ("effective_labels" ), d , config )
373
440
if err != nil {
374
441
return err
@@ -393,6 +460,14 @@ func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta i
393
460
updateMask = append (updateMask , "threatPreventionProfile" )
394
461
}
395
462
463
+ if d .HasChange ("custom_mirroring_profile" ) {
464
+ updateMask = append (updateMask , "customMirroringProfile" )
465
+ }
466
+
467
+ if d .HasChange ("custom_intercept_profile" ) {
468
+ updateMask = append (updateMask , "customInterceptProfile" )
469
+ }
470
+
396
471
if d .HasChange ("effective_labels" ) {
397
472
updateMask = append (updateMask , "labels" )
398
473
}
@@ -617,6 +692,40 @@ func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides
617
692
return v
618
693
}
619
694
695
+ func flattenNetworkSecuritySecurityProfileCustomMirroringProfile (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
696
+ if v == nil {
697
+ return nil
698
+ }
699
+ original := v .(map [string ]interface {})
700
+ if len (original ) == 0 {
701
+ return nil
702
+ }
703
+ transformed := make (map [string ]interface {})
704
+ transformed ["mirroring_endpoint_group" ] =
705
+ flattenNetworkSecuritySecurityProfileCustomMirroringProfileMirroringEndpointGroup (original ["mirroringEndpointGroup" ], d , config )
706
+ return []interface {}{transformed }
707
+ }
708
+ func flattenNetworkSecuritySecurityProfileCustomMirroringProfileMirroringEndpointGroup (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
709
+ return v
710
+ }
711
+
712
+ func flattenNetworkSecuritySecurityProfileCustomInterceptProfile (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
713
+ if v == nil {
714
+ return nil
715
+ }
716
+ original := v .(map [string ]interface {})
717
+ if len (original ) == 0 {
718
+ return nil
719
+ }
720
+ transformed := make (map [string ]interface {})
721
+ transformed ["intercept_endpoint_group" ] =
722
+ flattenNetworkSecuritySecurityProfileCustomInterceptProfileInterceptEndpointGroup (original ["interceptEndpointGroup" ], d , config )
723
+ return []interface {}{transformed }
724
+ }
725
+ func flattenNetworkSecuritySecurityProfileCustomInterceptProfileInterceptEndpointGroup (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
726
+ return v
727
+ }
728
+
620
729
func flattenNetworkSecuritySecurityProfileType (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
621
730
return v
622
731
}
@@ -755,6 +864,52 @@ func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesT
755
864
return v , nil
756
865
}
757
866
867
+ func expandNetworkSecuritySecurityProfileCustomMirroringProfile (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
868
+ l := v .([]interface {})
869
+ if len (l ) == 0 || l [0 ] == nil {
870
+ return nil , nil
871
+ }
872
+ raw := l [0 ]
873
+ original := raw .(map [string ]interface {})
874
+ transformed := make (map [string ]interface {})
875
+
876
+ transformedMirroringEndpointGroup , err := expandNetworkSecuritySecurityProfileCustomMirroringProfileMirroringEndpointGroup (original ["mirroring_endpoint_group" ], d , config )
877
+ if err != nil {
878
+ return nil , err
879
+ } else if val := reflect .ValueOf (transformedMirroringEndpointGroup ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
880
+ transformed ["mirroringEndpointGroup" ] = transformedMirroringEndpointGroup
881
+ }
882
+
883
+ return transformed , nil
884
+ }
885
+
886
+ func expandNetworkSecuritySecurityProfileCustomMirroringProfileMirroringEndpointGroup (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
887
+ return v , nil
888
+ }
889
+
890
+ func expandNetworkSecuritySecurityProfileCustomInterceptProfile (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
891
+ l := v .([]interface {})
892
+ if len (l ) == 0 || l [0 ] == nil {
893
+ return nil , nil
894
+ }
895
+ raw := l [0 ]
896
+ original := raw .(map [string ]interface {})
897
+ transformed := make (map [string ]interface {})
898
+
899
+ transformedInterceptEndpointGroup , err := expandNetworkSecuritySecurityProfileCustomInterceptProfileInterceptEndpointGroup (original ["intercept_endpoint_group" ], d , config )
900
+ if err != nil {
901
+ return nil , err
902
+ } else if val := reflect .ValueOf (transformedInterceptEndpointGroup ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
903
+ transformed ["interceptEndpointGroup" ] = transformedInterceptEndpointGroup
904
+ }
905
+
906
+ return transformed , nil
907
+ }
908
+
909
+ func expandNetworkSecuritySecurityProfileCustomInterceptProfileInterceptEndpointGroup (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
910
+ return v , nil
911
+ }
912
+
758
913
func expandNetworkSecuritySecurityProfileType (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
759
914
return v , nil
760
915
}
0 commit comments