@@ -102,6 +102,11 @@ func resourceNetworkZone() *schema.Resource {
102102 Optional : true ,
103103 Description : "Set this parameter to true in your request when you update the DefaultExemptIpZone to allow IPs through the blocklist." ,
104104 },
105+ "system" : {
106+ Type : schema .TypeBool ,
107+ Computed : true ,
108+ Description : "Indicates a system Network Zone" ,
109+ },
105110 },
106111 }
107112}
@@ -119,6 +124,10 @@ func resourceNetworkZoneCreate(ctx context.Context, d *schema.ResourceData, meta
119124 return diag .Errorf ("the DefaultExemptIpZone is a built-in Okta network zone and cannot be created. " +
120125 "Please use 'terraform import okta_network_zone.<resource_name> <zone_id>' to manage it" )
121126 }
127+ if d .Get ("name" ).(string ) == "BlockedIpZone" {
128+ return diag .Errorf ("the BlockedIpZone is a built-in Okta network zone and cannot be created. " +
129+ "Please use 'terraform import okta_network_zone.<resource_name> <zone_id>' to manage it" )
130+ }
122131 zone , _ , err := getOktaV6ClientFromMetadata (meta ).NetworkZoneAPI .CreateNetworkZone (ctx ).Zone (payload ).Execute ()
123132 if err != nil {
124133 return diag .Errorf ("failed to create network zone: %v" , err )
@@ -181,7 +190,10 @@ func resourceNetworkZoneUpdate(ctx context.Context, d *schema.ResourceData, meta
181190 if err != nil {
182191 return diag .Errorf ("failed to update network zone: %v" , err )
183192 }
184- if d .Get ("name" ).(string ) != "DefaultExemptIpZone" {
193+
194+ name := d .Get ("name" ).(string )
195+
196+ if name != "DefaultExemptIpZone" && name != "BlockedIpZone" {
185197 if d .Get ("status" ).(string ) == "ACTIVE" {
186198 zone , _ , err = getOktaV6ClientFromMetadata (meta ).NetworkZoneAPI .ActivateNetworkZone (ctx , d .Id ()).Execute ()
187199 if err != nil {
@@ -204,9 +216,9 @@ func resourceNetworkZoneUpdate(ctx context.Context, d *schema.ResourceData, meta
204216}
205217
206218func resourceNetworkZoneDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
207- // Built-in zones like DefaultExemptIpZone cannot be deleted from Okta,
208- // so just remove them from state.
209- if d .Get ("name" ).(string ) == "DefaultExemptIpZone" {
219+ // System zones (e.g. DefaultExemptIpZone, BlockedIpZone) cannot be deleted
220+ // from Okta, so just remove them from state.
221+ if d .Get ("system" ).( bool ) || d . Get ( " name" ).(string ) == "DefaultExemptIpZone" {
210222 return nil
211223 }
212224 _ , resp , err := getOktaV6ClientFromMetadata (meta ).NetworkZoneAPI .DeactivateNetworkZone (ctx , d .Id ()).Execute ()
@@ -229,6 +241,10 @@ func buildNetworkZone(d *schema.ResourceData) (v6okta.ListNetworkZones200Respons
229241 ipnz .SetName (d .Get ("name" ).(string ))
230242 ipnz .SetType (zoneType )
231243 ipnz .SetUsage (d .Get ("usage" ).(string ))
244+ if d .Get ("name" ).(string ) == "BlockedIpZone" {
245+ ipnz .SetSystem (d .Get ("system" ).(bool ))
246+ }
247+
232248 if values , ok := d .GetOk ("gateways" ); ok {
233249 ipnz .SetGateways (buildAddressObjList (values .(* schema.Set )))
234250 }
@@ -442,6 +458,7 @@ func mapNetworkZoneToState(d *schema.ResourceData, data *v6okta.ListNetworkZones
442458 _ = d .Set ("type" , v .GetType ())
443459 _ = d .Set ("status" , v .GetStatus ())
444460 _ = d .Set ("usage" , v .GetUsage ())
461+ _ = d .Set ("system" , v .GetSystem ())
445462 err = utils .SetNonPrimitives (d , map [string ]interface {}{
446463 "gateways" : flattenAddresses (v .GetGateways ()),
447464 "proxies" : flattenAddresses (v .GetProxies ()),
0 commit comments