@@ -64,6 +64,11 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
6464 Required : true ,
6565 },
6666
67+ "overprovision" : & schema.Schema {
68+ Type : schema .TypeBool ,
69+ Optional : true ,
70+ },
71+
6772 "os_profile" : & schema.Schema {
6873 Type : schema .TypeSet ,
6974 Required : true ,
@@ -250,7 +255,6 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
250255 "load_balancer_backend_address_pool_ids" : & schema.Schema {
251256 Type : schema .TypeSet ,
252257 Optional : true ,
253- Computed : true ,
254258 Elem : & schema.Schema {Type : schema .TypeString },
255259 Set : schema .HashString ,
256260 },
@@ -276,12 +280,11 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
276280 "image" : & schema.Schema {
277281 Type : schema .TypeString ,
278282 Optional : true ,
279- Computed : true ,
280283 },
281284
282285 "vhd_containers" : & schema.Schema {
283286 Type : schema .TypeSet ,
284- Required : true ,
287+ Optional : true ,
285288 Elem : & schema.Schema {Type : schema .TypeString },
286289 Set : schema .HashString ,
287290 },
@@ -294,7 +297,6 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
294297 "os_type" : & schema.Schema {
295298 Type : schema .TypeString ,
296299 Optional : true ,
297- Computed : true ,
298300 },
299301
300302 "create_option" : & schema.Schema {
@@ -378,6 +380,7 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf
378380 }
379381
380382 updatePolicy := d .Get ("upgrade_policy_mode" ).(string )
383+ overprovision := d .Get ("overprovision" ).(bool )
381384 scaleSetProps := compute.VirtualMachineScaleSetProperties {
382385 UpgradePolicy : & compute.UpgradePolicy {
383386 Mode : compute .UpgradeMode (updatePolicy ),
@@ -387,6 +390,7 @@ func resourceArmVirtualMachineScaleSetCreate(d *schema.ResourceData, meta interf
387390 StorageProfile : & storageProfile ,
388391 OsProfile : osProfile ,
389392 },
393+ Overprovision : & overprovision ,
390394 }
391395
392396 scaleSetParams := compute.VirtualMachineScaleSet {
@@ -444,6 +448,7 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac
444448 properties := resp .VirtualMachineScaleSetProperties
445449
446450 d .Set ("upgrade_policy_mode" , properties .UpgradePolicy .Mode )
451+ d .Set ("overprovision" , properties .Overprovision )
447452
448453 if err := d .Set ("os_profile" , flattenAzureRMVirtualMachineScaleSetOsProfile (properties .VirtualMachineProfile .OsProfile )); err != nil {
449454 return fmt .Errorf ("[DEBUG] Error setting Virtual Machine Scale Set OS Profile error: %#v" , err )
@@ -619,12 +624,14 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual
619624 }
620625
621626 if properties .LoadBalancerBackendAddressPools != nil {
622- addressPools := make ([]string , 0 , len (* properties .LoadBalancerBackendAddressPools ))
627+ addressPools := make ([]interface {} , 0 , len (* properties .LoadBalancerBackendAddressPools ))
623628 for _ , pool := range * properties .LoadBalancerBackendAddressPools {
624629 addressPools = append (addressPools , * pool .ID )
625630 }
626- config ["load_balancer_backend_address_pool_ids" ] = addressPools
631+ config ["load_balancer_backend_address_pool_ids" ] = schema . NewSet ( schema . HashString , addressPools )
627632 }
633+
634+ ipConfigs = append (ipConfigs , config )
628635 }
629636
630637 s ["ip_configuration" ] = ipConfigs
@@ -656,14 +663,17 @@ func flattenAzureRmVirtualMachineScaleSetStorageProfileOSDisk(profile *compute.V
656663 result ["image" ] = * profile .Image .URI
657664 }
658665
659- containers := make ([]interface {}, 0 , len (* profile .VhdContainers ))
660- for _ , container := range * profile .VhdContainers {
661- containers = append (containers , container )
666+ if profile .VhdContainers != nil {
667+ containers := make ([]interface {}, 0 , len (* profile .VhdContainers ))
668+ for _ , container := range * profile .VhdContainers {
669+ containers = append (containers , container )
670+ }
671+ result ["vhd_containers" ] = schema .NewSet (schema .HashString , containers )
662672 }
663- result ["vhd_containers" ] = schema .NewSet (schema .HashString , containers )
664673
665674 result ["caching" ] = profile .Caching
666675 result ["create_option" ] = profile .CreateOption
676+ result ["os_type" ] = profile .OsType
667677
668678 return []interface {}{result }
669679}
@@ -721,9 +731,6 @@ func resourceArmVirtualMachineScaleSetStorageProfileOsDiskHash(v interface{}) in
721731 if m ["image" ] != nil {
722732 buf .WriteString (fmt .Sprintf ("%s-" , m ["image" ].(string )))
723733 }
724- if m ["os_type" ] != nil {
725- buf .WriteString (fmt .Sprintf ("%s-" , m ["os_type" ].(string )))
726- }
727734
728735 return hashcode .String (buf .String ())
729736}
@@ -813,10 +820,18 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) *
813820 },
814821 },
815822 }
816- //TODO: Add the support for the load balancers when it drops
817- //if v := ipconfig["load_balancer_backend_address_pool_ids"]; v != nil {
818- //
819- //}
823+
824+ if v := ipconfig ["load_balancer_backend_address_pool_ids" ]; v != nil {
825+ pools := v .(* schema.Set ).List ()
826+ resources := make ([]compute.SubResource , 0 , len (pools ))
827+ for _ , p := range pools {
828+ id := p .(string )
829+ resources = append (resources , compute.SubResource {
830+ ID : & id ,
831+ })
832+ }
833+ ipConfiguration .LoadBalancerBackendAddressPools = & resources
834+ }
820835
821836 ipConfigurations = append (ipConfigurations , ipConfiguration )
822837 }
@@ -897,25 +912,25 @@ func expandAzureRMVirtualMachineScaleSetsStorageProfileOsDisk(d *schema.Resource
897912 osType := osDiskConfig ["os_type" ].(string )
898913 createOption := osDiskConfig ["create_option" ].(string )
899914
900- var vhdContainers []string
901- containers := osDiskConfig ["vhd_containers" ].(* schema.Set ).List ()
902- for _ , v := range containers {
903- str := v .(string )
904- vhdContainers = append (vhdContainers , str )
905- }
906-
907915 osDisk := & compute.VirtualMachineScaleSetOSDisk {
908- Name : & name ,
909- Caching : compute .CachingTypes (caching ),
910- OsType : compute .OperatingSystemTypes (osType ),
911- CreateOption : compute .DiskCreateOptionTypes (createOption ),
912- VhdContainers : & vhdContainers ,
916+ Name : & name ,
917+ Caching : compute .CachingTypes (caching ),
918+ OsType : compute .OperatingSystemTypes (osType ),
919+ CreateOption : compute .DiskCreateOptionTypes (createOption ),
913920 }
914921
915922 if image != "" {
916923 osDisk .Image = & compute.VirtualHardDisk {
917924 URI : & image ,
918925 }
926+ } else {
927+ var vhdContainers []string
928+ containers := osDiskConfig ["vhd_containers" ].(* schema.Set ).List ()
929+ for _ , v := range containers {
930+ str := v .(string )
931+ vhdContainers = append (vhdContainers , str )
932+ }
933+ osDisk .VhdContainers = & vhdContainers
919934 }
920935
921936 return osDisk , nil
0 commit comments