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_api_management - virtual_network_configuration now updates correctly outside of virtual_network_type #24569

Merged
merged 1 commit into from
Feb 6, 2024
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
14 changes: 11 additions & 3 deletions internal/services/apimanagement/api_management_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@ func resourceApiManagementServiceUpdate(d *pluginsdk.ResourceData, meta interfac
defer cancel()

sku := expandAzureRmApiManagementSkuName(d.Get("sku_name").(string))
virtualNetworkType := d.Get("virtual_network_type").(string)
virtualNetworkConfiguration := expandAzureRmApiManagementVirtualNetworkConfigurations(d)

log.Printf("[INFO] preparing arguments for API Management Service creation.")

Expand Down Expand Up @@ -1024,18 +1026,24 @@ func resourceApiManagementServiceUpdate(d *pluginsdk.ResourceData, meta interfac
}

if d.HasChange("virtual_network_type") {
virtualNetworkType := d.Get("virtual_network_type").(string)
props.VirtualNetworkType = pointer.To(apimanagementservice.VirtualNetworkType(virtualNetworkType))

if virtualNetworkType != string(apimanagementservice.VirtualNetworkTypeNone) {
virtualNetworkConfiguration := expandAzureRmApiManagementVirtualNetworkConfigurations(d)
if virtualNetworkConfiguration == nil {
return fmt.Errorf("You must specify 'virtual_network_configuration' when 'virtual_network_type' is %q", virtualNetworkType)
}
props.VirtualNetworkConfiguration = virtualNetworkConfiguration
}
}

if d.HasChange("virtual_network_configuration") {
props.VirtualNetworkConfiguration = virtualNetworkConfiguration
if virtualNetworkType == string(apimanagementservice.VirtualNetworkTypeNone) {
if virtualNetworkConfiguration != nil {
return fmt.Errorf("You must specify 'virtual_network_type' when specifying 'virtual_network_configuration'")
}
}
}

if d.HasChanges("security", "protocols") {
customProperties, err := expandApiManagementCustomProperties(d, sku.Name == apimanagementservice.SkuTypeConsumption)
if err != nil {
Expand Down
Loading