@@ -112,7 +112,14 @@ func ResourceDNSZone() *schema.Resource {
112
112
Type : schema .TypeString ,
113
113
Optional : true ,
114
114
Computed : true ,
115
- Description : `Specifies the status of the public zone.` ,
115
+ Description : `The status of the zone.` ,
116
+ },
117
+ "proxy_pattern" : {
118
+ Type : schema .TypeString ,
119
+ Optional : true ,
120
+ Computed : true ,
121
+ ForceNew : true ,
122
+ Description : `The recursive resolution proxy mode for subdomains of the private zone.` ,
116
123
},
117
124
"masters" : {
118
125
Type : schema .TypeSet ,
@@ -176,6 +183,7 @@ func resourceDNSZoneCreate(ctx context.Context, d *schema.ResourceData, meta int
176
183
ZoneType : zoneType ,
177
184
EnterpriseProjectID : cfg .GetEnterpriseProjectID (d ),
178
185
Router : resourceDNSRouter (d , region ),
186
+ ProxyPattern : d .Get ("proxy_pattern" ).(string ),
179
187
}
180
188
181
189
log .Printf ("[DEBUG] Create options: %#v" , createOpts )
@@ -242,11 +250,7 @@ func resourceDNSZoneCreate(ctx context.Context, d *schema.ResourceData, meta int
242
250
// After zone is created, the status is ACTIVE (ENABLE).
243
251
// This action cannot be called repeatedly.
244
252
if v , ok := d .GetOk ("status" ); ok && v != "ENABLE" {
245
- if zoneType == "private" {
246
- return diag .Errorf ("The private zone do not support updating status." )
247
- }
248
-
249
- if err := updatePublicZoneStatus (ctx , d , dnsClient , d .Timeout (schema .TimeoutCreate )); err != nil {
253
+ if err := updateZoneStatus (ctx , d , dnsClient , d .Timeout (schema .TimeoutCreate )); err != nil {
250
254
return diag .FromErr (err )
251
255
}
252
256
}
@@ -309,8 +313,8 @@ func resourceDNSZoneRead(_ context.Context, d *schema.ResourceData, meta interfa
309
313
d .Set ("zone_type" , zoneInfo .ZoneType ),
310
314
d .Set ("router" , flattenPrivateZoneRouters (zoneInfo .Routers )),
311
315
d .Set ("enterprise_project_id" , zoneInfo .EnterpriseProjectID ),
312
- // The private zone also returns the "status" attribute.
313
316
d .Set ("status" , parseZoneStatus (zoneInfo .Status )),
317
+ d .Set ("proxy_pattern" , zoneInfo .ProxyPattern ),
314
318
// Attributes
315
319
d .Set ("masters" , zoneInfo .Masters ),
316
320
)
@@ -386,18 +390,15 @@ func resourceDNSZoneUpdate(ctx context.Context, d *schema.ResourceData, meta int
386
390
}
387
391
}
388
392
389
- if d .HasChange ("router" ) && zoneType == "private" {
390
- if err := updateDNSZoneRouters (ctx , d , dnsClient , region ); err != nil {
393
+ if d .HasChange ("status" ) {
394
+ if err := updateZoneStatus (ctx , d , dnsClient , d . Timeout ( schema . TimeoutUpdate ) ); err != nil {
391
395
return diag .FromErr (err )
392
396
}
393
397
}
394
398
395
- if d .HasChange ("status" ) {
396
- if zoneType == "private" {
397
- return diag .Errorf ("The private zone do not support updating status." )
398
- }
399
-
400
- if err := updatePublicZoneStatus (ctx , d , dnsClient , d .Timeout (schema .TimeoutUpdate )); err != nil {
399
+ // This operation is supported only when the zone status is enabled.
400
+ if d .HasChange ("router" ) && zoneType == "private" {
401
+ if err := updateDNSZoneRouters (ctx , d , dnsClient , region ); err != nil {
401
402
return diag .FromErr (err )
402
403
}
403
404
}
@@ -514,14 +515,14 @@ func updateDNSZoneRouters(ctx context.Context, d *schema.ResourceData, client *g
514
515
return nil
515
516
}
516
517
517
- func updatePublicZoneStatus (ctx context.Context , d * schema.ResourceData , client * golangsdk.ServiceClient , timeout time.Duration ) error {
518
+ func updateZoneStatus (ctx context.Context , d * schema.ResourceData , client * golangsdk.ServiceClient , timeout time.Duration ) error {
518
519
opts := zones.UpdateStatusOpts {
519
520
ZoneId : d .Id (),
520
521
Status : d .Get ("status" ).(string ),
521
522
}
522
523
err := zones .UpdateZoneStatus (client , opts )
523
524
if err != nil {
524
- return fmt .Errorf ("error updating public zone status: %s" , err )
525
+ return fmt .Errorf ("error updating the status of the zone : %s" , err )
525
526
}
526
527
527
528
stateConf := & resource.StateChangeConf {
@@ -534,7 +535,7 @@ func updatePublicZoneStatus(ctx context.Context, d *schema.ResourceData, client
534
535
535
536
_ , err = stateConf .WaitForStateContext (ctx )
536
537
if err != nil {
537
- return fmt .Errorf ("error waiting for updating public zone status completed: %s" , err )
538
+ return fmt .Errorf ("error waiting for updating the zone status completed: %s" , err )
538
539
}
539
540
540
541
return nil
0 commit comments