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_mssql_managed_instance_security_alert_policy - fix error when updating with empty storage attributes #24553

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,24 @@ func resourceMsSqlManagedInstanceSecurityAlertPolicyUpdate(d *pluginsdk.Resource
}
}

props.StorageAccountAccessKey = utils.String(d.Get("storage_account_access_key").(string))
if d.HasChange("storage_account_access_key") {
props.StorageAccountAccessKey = utils.String(d.Get("storage_account_access_key").(string))
}

// StorageAccountAccessKey cannot be passed in if it is empty. The api returns this as empty so we need to nil it before sending it back to the api
if props.StorageAccountAccessKey != nil && *props.StorageAccountAccessKey == "" {
props.StorageAccountAccessKey = nil
}

if d.HasChange("storage_endpoint") {
props.StorageEndpoint = utils.String(d.Get("storage_endpoint").(string))
}

// StorageEndpoint cannot be passed in if it is empty. The api returns this as empty so we need to nil it before sending it back to the api
if props.StorageEndpoint != nil && *props.StorageEndpoint == "" {
props.StorageEndpoint = nil
}

future, err := client.CreateOrUpdate(ctx, resourceGroupName, instanceName, existing)
if err != nil {
return fmt.Errorf("updating managed instance security alert policy: %v", err)
Expand Down
Loading