@@ -378,22 +378,28 @@ func resourceComputeInstance() *schema.Resource {
378
378
379
379
"scheduling" : & schema.Schema {
380
380
Type : schema .TypeList ,
381
+ MaxItems : 1 ,
381
382
Optional : true ,
383
+ Computed : true ,
382
384
Elem : & schema.Resource {
383
385
Schema : map [string ]* schema.Schema {
384
386
"on_host_maintenance" : & schema.Schema {
385
387
Type : schema .TypeString ,
386
388
Optional : true ,
389
+ Computed : true ,
387
390
},
388
391
389
392
"automatic_restart" : & schema.Schema {
390
393
Type : schema .TypeBool ,
391
394
Optional : true ,
395
+ Default : true ,
392
396
},
393
397
394
398
"preemptible" : & schema.Schema {
395
399
Type : schema .TypeBool ,
396
400
Optional : true ,
401
+ Default : false ,
402
+ ForceNew : true ,
397
403
},
398
404
},
399
405
},
@@ -787,6 +793,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
787
793
if val , ok := d .GetOk (prefix + ".on_host_maintenance" ); ok {
788
794
scheduling .OnHostMaintenance = val .(string )
789
795
}
796
+ scheduling .ForceSendFields = []string {"AutomaticRestart" , "Preemptible" }
790
797
791
798
// Read create timeout
792
799
var createTimeout int
@@ -1060,6 +1067,9 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
1060
1067
d .Set ("attached_disk" , attachedDisks )
1061
1068
d .Set ("scratch_disk" , scratchDisks )
1062
1069
1070
+ scheduling , _ := flattenScheduling (instance .Scheduling )
1071
+ d .Set ("scheduling" , scheduling )
1072
+
1063
1073
d .Set ("self_link" , instance .SelfLink )
1064
1074
d .SetId (instance .Name )
1065
1075
@@ -1168,14 +1178,13 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
1168
1178
if val , ok := d .GetOk (prefix + ".automatic_restart" ); ok {
1169
1179
scheduling .AutomaticRestart = googleapi .Bool (val .(bool ))
1170
1180
}
1171
-
1172
1181
if val , ok := d .GetOk (prefix + ".preemptible" ); ok {
1173
1182
scheduling .Preemptible = val .(bool )
1174
1183
}
1175
-
1176
1184
if val , ok := d .GetOk (prefix + ".on_host_maintenance" ); ok {
1177
1185
scheduling .OnHostMaintenance = val .(string )
1178
1186
}
1187
+ scheduling .ForceSendFields = []string {"AutomaticRestart" , "Preemptible" }
1179
1188
1180
1189
op , err := config .clientCompute .Instances .SetScheduling (project ,
1181
1190
zone , d .Id (), scheduling ).Do ()
0 commit comments