Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_application_gateway: fix panic in backend and probe pick hostname validation #3438

Merged
merged 2 commits into from
May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,28 +1146,30 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
}

for _, backendHttpSettings := range *backendHTTPSettingsCollection {
backendHttpSettingsProperties := *backendHttpSettings.ApplicationGatewayBackendHTTPSettingsPropertiesFormat
if backendHttpSettingsProperties.HostName != nil {
hostName := *backendHttpSettingsProperties.HostName
pick := *backendHttpSettingsProperties.PickHostNameFromBackendAddress
if props := backendHttpSettings.ApplicationGatewayBackendHTTPSettingsPropertiesFormat; props != nil {
if props.HostName == nil || props.PickHostNameFromBackendAddress == nil {
continue
}

if hostName != "" && pick {
if *props.HostName != "" && *props.PickHostNameFromBackendAddress {
return fmt.Errorf("Only one of `host_name` or `pick_host_name_from_backend_address` can be set")
}
}
}

for _, probe := range *probes {
probeProperties := *probe.ApplicationGatewayProbePropertiesFormat
host := *probeProperties.Host
pick := *probeProperties.PickHostNameFromBackendHTTPSettings
if props := probe.ApplicationGatewayProbePropertiesFormat; props != nil {
if props.Host == nil || props.PickHostNameFromBackendHTTPSettings == nil {
continue
}

if host == "" && !pick {
return fmt.Errorf("One of `host` or `pick_host_name_from_backend_http_settings` must be set")
}
if *props.Host == "" && !*props.PickHostNameFromBackendHTTPSettings {
return fmt.Errorf("One of `host` or `pick_host_name_from_backend_http_settings` must be set")
}

if host != "" && pick {
return fmt.Errorf("Only one of `host` or `pick_host_name_from_backend_http_settings` can be set")
if *props.Host != "" && *props.PickHostNameFromBackendHTTPSettings {
return fmt.Errorf("Only one of `host` or `pick_host_name_from_backend_http_settings` can be set")
}
}
}

Expand Down