@@ -77,8 +77,11 @@ func resourceSqlDatabaseInstance() *schema.Resource {
77
77
Type : schema .TypeString ,
78
78
Optional : true ,
79
79
DiffSuppressFunc : suppressFirstGen ,
80
- // Set computed instead of default because this property is for second-gen only.
81
- Computed : true ,
80
+ // Set computed instead of default because this property is for second-gen
81
+ // only. The default when not provided is ZONAL, which means no explicit HA
82
+ // configuration.
83
+ Computed : true ,
84
+ ValidateFunc : validation .StringInSlice ([]string {"REGIONAL" , "ZONAL" }, false ),
82
85
},
83
86
"backup_configuration" : & schema.Schema {
84
87
Type : schema .TypeList ,
@@ -350,18 +353,19 @@ func resourceSqlDatabaseInstance() *schema.Resource {
350
353
}
351
354
}
352
355
353
- // Suppress diff with any disk_autoresize value on 1st Generation Instances
356
+ // Suppress diff with any attribute value that is not supported on 1st Generation
357
+ // Instances
354
358
func suppressFirstGen (k , old , new string , d * schema.ResourceData ) bool {
355
359
settingsList := d .Get ("settings" ).([]interface {})
356
360
357
361
settings := settingsList [0 ].(map [string ]interface {})
358
362
tier := settings ["tier" ].(string )
359
363
matched , err := regexp .MatchString ("db*" , tier )
360
364
if err != nil {
361
- log .Printf ("[ERR] error with regex in diff supression for disk_autoresize : %s" , err )
365
+ log .Printf ("[ERR] error with regex in diff supression for %s : %s" , k , err )
362
366
}
363
367
if ! matched {
364
- log .Printf ("[DEBUG] suppressing diff on disk_autoresize due to 1st gen instance type" )
368
+ log .Printf ("[DEBUG] suppressing diff on %s due to 1st gen instance type" , k )
365
369
return true
366
370
}
367
371
return false
@@ -427,7 +431,8 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
427
431
settings .CrashSafeReplicationEnabled = v .(bool )
428
432
}
429
433
430
- settings .StorageAutoResize = _settings ["disk_autoresize" ].(* bool )
434
+ autoResize := _settings ["disk_autoresize" ].(bool )
435
+ settings .StorageAutoResize = & autoResize
431
436
432
437
if v , ok := _settings ["disk_size" ]; ok && v .(int ) > 0 {
433
438
settings .DataDiskSizeGb = int64 (v .(int ))
@@ -729,10 +734,12 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
729
734
_settingsList := _settingsListCast .([]interface {})
730
735
731
736
_settings := _settingsList [0 ].(map [string ]interface {})
737
+ _autoResize := _settings ["disk_autoresize" ].(bool )
738
+
732
739
settings := & sqladmin.Settings {
733
740
Tier : _settings ["tier" ].(string ),
734
741
SettingsVersion : instance .Settings .SettingsVersion ,
735
- StorageAutoResize : _settings [ "disk_autoresize" ].( * bool ) ,
742
+ StorageAutoResize : & _autoResize ,
736
743
ForceSendFields : []string {"StorageAutoResize" },
737
744
}
738
745
0 commit comments