Skip to content

Commit

Permalink
Merge pull request #1209 from djsly/issue-901
Browse files Browse the repository at this point in the history
Additional VMSS properties (issues #1210 & #1226
  • Loading branch information
katbyte authored Jun 5, 2018
2 parents 3c5216f + e8242fd commit 4683093
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 414 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ IMPROVEMENTS:
* `azurerm_app_service` - allow changing `client_affinity_enabled` without requiring a resource recreation ([#993](https://github.com/terraform-providers/terraform-provider-azurerm/issues/993))
* `azurerm_app_service` - support for configuring `LocalSCM` source control ([#826](https://github.com/terraform-providers/terraform-provider-azurerm/issues/826))
* `azurerm_app_service` - returning a clearer error message when the name (which needs to be globally unique) is in use ([#1037](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1037))
* `azurerm_cosmosdb_account` - increasing the maximum value for `max_interval_in_seconds` from 100s to 86400s (1 day) [[#1000](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1000)]
* `azurerm_cosmosdb_account` - increasing the maximum value for `max_interval_in_seconds` from 100s to 86400s (1 day) [[#1000](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1000)]
* `azurerm_function_app` - returning a clearer error message when the name (which needs to be globally unique) is in use ([#1037](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1037))
* `azurerm_network_interface` - support for attaching to Application Gateways ([#1027](https://github.com/terraform-providers/terraform-provider-azurerm/issues/1027))
* `azurerm_traffic_manager_endpoint` - adding support for `geo_mappings` ([#986](https://github.com/terraform-providers/terraform-provider-azurerm/issues/986))
Expand Down Expand Up @@ -352,4 +352,4 @@ IMPROVEMENTS:
* core - Upgrading `Azure/azure-sdk-for-go` to v11.2.2-beta ([#594](https://github.com/terraform-providers/terraform-provider-azurerm/issues/594))
* core - upgrading `Azure/go-autorest` to v9.5.2 ([#617](https://github.com/terraform-providers/terraform-provider-azurerm/issues/617))
* core - skipping Resource Provider Registration in AutoRest when opted-out ([#630](https://github.com/terraform-providers/terraform-provider-azurerm/issues/630))
* `azurerm_app_service` - exposing the Default Hostname as a Computed field
* `azurerm_app_service` - exposing the Default Hostname as a Computed field
61 changes: 59 additions & 2 deletions azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,32 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
Optional: true,
},

"ip_forwarding": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"network_security_group_id": {
Type: schema.TypeString,
Optional: true,
},

"dns_settings": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dns_servers": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},

"ip_configuration": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -776,7 +797,6 @@ func resourceArmVirtualMachineScaleSetRead(d *schema.ResourceData, meta interfac
if upgradePolicy := properties.UpgradePolicy; upgradePolicy != nil {
d.Set("upgrade_policy_mode", upgradePolicy.Mode)
}

d.Set("overprovision", properties.Overprovision)
d.Set("single_placement_group", properties.SinglePlacementGroup)

Expand Down Expand Up @@ -1036,10 +1056,27 @@ func flattenAzureRmVirtualMachineScaleSetNetworkProfile(profile *compute.Virtual
s["accelerated_networking"] = *v
}

if v := netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.EnableIPForwarding; v != nil {
s["ip_forwarding"] = *v
}

if v := netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.NetworkSecurityGroup; v != nil {
s["network_security_group_id"] = *v.ID
}

if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings != nil {
dnsSetting := make(map[string]interface{})
dnsServers := make([]string, 0, len(*netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers))
if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers != nil {
for _, dnsServer := range *netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.DNSSettings.DNSServers {
dnsServers = append(dnsServers, dnsServer)
}
dnsSetting["dns_servers"] = dnsServers
}

s["dns_settings"] = []interface{}{dnsSetting}
}

if netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations != nil {
ipConfigs := make([]map[string]interface{}, 0, len(*netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations))
for _, ipConfig := range *netConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations {
Expand Down Expand Up @@ -1394,7 +1431,25 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) *
name := config["name"].(string)
primary := config["primary"].(bool)
acceleratedNetworking := config["accelerated_networking"].(bool)

ipForwarding := config["ip_forwarding"].(bool)

dnsSettingsConfigs := config["dns_settings"].([]interface{})
dnsSettings := compute.VirtualMachineScaleSetNetworkConfigurationDNSSettings{}
for _, dnsSettingsConfig := range dnsSettingsConfigs {
dns_settings := dnsSettingsConfig.(map[string]interface{})

if v := dns_settings["dns_servers"]; v != nil {
dns_servers := dns_settings["dns_servers"].([]interface{})
if len(dns_servers) > 0 {
var dnsServers []string
for _, v := range dns_servers {
str := v.(string)
dnsServers = append(dnsServers, str)
}
dnsSettings.DNSServers = &dnsServers
}
}
}
ipConfigurationConfigs := config["ip_configuration"].([]interface{})
ipConfigurations := make([]compute.VirtualMachineScaleSetIPConfiguration, 0, len(ipConfigurationConfigs))
for _, ipConfigConfig := range ipConfigurationConfigs {
Expand Down Expand Up @@ -1486,6 +1541,8 @@ func expandAzureRmVirtualMachineScaleSetNetworkProfile(d *schema.ResourceData) *
Primary: &primary,
IPConfigurations: &ipConfigurations,
EnableAcceleratedNetworking: &acceleratedNetworking,
EnableIPForwarding: &ipForwarding,
DNSSettings: &dnsSettings,
},
}

Expand Down
Loading

0 comments on commit 4683093

Please sign in to comment.