Skip to content

Commit

Permalink
azurerm_mssql_managed_instance_security_alert_policy - fix error when…
Browse files Browse the repository at this point in the history
… updating with empty storage attributes
  • Loading branch information
mbfrahry committed Jan 18, 2024
1 parent 7020049 commit 46a1aed
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 46a1aed

Please sign in to comment.