@@ -625,12 +625,22 @@ func expandComputeInstance(project string, zone *compute.Zone, d *schema.Resourc
625
625
disks = append (disks , disk )
626
626
}
627
627
628
- prefix := "scheduling.0"
629
- scheduling := & computeBeta.Scheduling {
630
- AutomaticRestart : googleapi .Bool (d .Get (prefix + ".automatic_restart" ).(bool )),
631
- Preemptible : d .Get (prefix + ".preemptible" ).(bool ),
632
- OnHostMaintenance : d .Get (prefix + ".on_host_maintenance" ).(string ),
633
- ForceSendFields : []string {"AutomaticRestart" , "Preemptible" },
628
+ sch := d .Get ("scheduling" ).([]interface {})
629
+ var scheduling * computeBeta.Scheduling
630
+ if len (sch ) == 0 {
631
+ // TF doesn't do anything about defaults inside of nested objects, so if
632
+ // scheduling hasn't been set, then send it with its default values.
633
+ scheduling = & computeBeta.Scheduling {
634
+ AutomaticRestart : googleapi .Bool (true ),
635
+ }
636
+ } else {
637
+ prefix := "scheduling.0"
638
+ scheduling = & computeBeta.Scheduling {
639
+ AutomaticRestart : googleapi .Bool (d .Get (prefix + ".automatic_restart" ).(bool )),
640
+ Preemptible : d .Get (prefix + ".preemptible" ).(bool ),
641
+ OnHostMaintenance : d .Get (prefix + ".on_host_maintenance" ).(string ),
642
+ ForceSendFields : []string {"AutomaticRestart" , "Preemptible" },
643
+ }
634
644
}
635
645
636
646
metadata , err := resourceInstanceMetadata (d )
0 commit comments