@@ -65,8 +65,44 @@ func ResourceNetworkSecuritySecurityProfile() *schema.Resource {
6565 Type : schema .TypeString ,
6666 Required : true ,
6767 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" },
70106 },
71107 "description" : {
72108 Type : schema .TypeString ,
@@ -155,6 +191,7 @@ and threat overrides, the threat overrides action is applied.`,
155191 },
156192 },
157193 },
194+ ConflictsWith : []string {"custom_mirroring_profile" , "custom_intercept_profile" },
158195 },
159196 "create_time" : {
160197 Type : schema .TypeString ,
@@ -217,6 +254,18 @@ func resourceNetworkSecuritySecurityProfileCreate(d *schema.ResourceData, meta i
217254 } else if v , ok := d .GetOkExists ("threat_prevention_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (threatPreventionProfileProp )) && (ok || ! reflect .DeepEqual (v , threatPreventionProfileProp )) {
218255 obj ["threatPreventionProfile" ] = threatPreventionProfileProp
219256 }
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+ }
220269 typeProp , err := expandNetworkSecuritySecurityProfileType (d .Get ("type" ), d , config )
221270 if err != nil {
222271 return err
@@ -333,6 +382,12 @@ func resourceNetworkSecuritySecurityProfileRead(d *schema.ResourceData, meta int
333382 if err := d .Set ("threat_prevention_profile" , flattenNetworkSecuritySecurityProfileThreatPreventionProfile (res ["threatPreventionProfile" ], d , config )); err != nil {
334383 return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
335384 }
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+ }
336391 if err := d .Set ("type" , flattenNetworkSecuritySecurityProfileType (res ["type" ], d , config )); err != nil {
337392 return fmt .Errorf ("Error reading SecurityProfile: %s" , err )
338393 }
@@ -369,6 +424,18 @@ func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta i
369424 } else if v , ok := d .GetOkExists ("threat_prevention_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , threatPreventionProfileProp )) {
370425 obj ["threatPreventionProfile" ] = threatPreventionProfileProp
371426 }
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+ }
372439 labelsProp , err := expandNetworkSecuritySecurityProfileEffectiveLabels (d .Get ("effective_labels" ), d , config )
373440 if err != nil {
374441 return err
@@ -393,6 +460,14 @@ func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta i
393460 updateMask = append (updateMask , "threatPreventionProfile" )
394461 }
395462
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+
396471 if d .HasChange ("effective_labels" ) {
397472 updateMask = append (updateMask , "labels" )
398473 }
@@ -617,6 +692,40 @@ func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides
617692 return v
618693}
619694
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+
620729func flattenNetworkSecuritySecurityProfileType (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
621730 return v
622731}
@@ -755,6 +864,52 @@ func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesT
755864 return v , nil
756865}
757866
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+
758913func expandNetworkSecuritySecurityProfileType (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
759914 return v , nil
760915}
0 commit comments